<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/toolbarColorScheme(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE18toolbarColorScheme_3forQrAA0eF0OSg_AA16ToolbarPlacementVdtF"
  },
  "title" : "toolbarColorScheme(_:for:)"
}
-->

# toolbarColorScheme(_:for:)

Specifies the preferred color scheme of a bar managed by SwiftUI.

```
nonisolated func toolbarColorScheme(_ colorScheme: ColorScheme?, for bars: ToolbarPlacement...) -> some View
```

## Parameters

`colorScheme`

The preferred color scheme of the background
of the bar.

`bars`

The bars to update the color scheme of or
[`automatic`](/documentation/SwiftUI/ToolbarPlacement/automatic) if empty.

## Discussion

The preferred color scheme flows up to the nearest container
that renders a bar. This could be a [`NavigationView`](/documentation/SwiftUI/NavigationView) or [`TabView`](/documentation/SwiftUI/TabView)
in iOS, or the root view of a [`WindowGroup`](/documentation/SwiftUI/WindowGroup) in macOS. Pass in a value
of nil to match the current system’s color scheme.

This examples shows a view that renders the navigation bar with a blue
background and dark color scheme:

```
TabView {
    NavigationView {
        ContentView()
            .toolbarBackground(.blue)
            .toolbarColorScheme(.dark)
    }
    // other tabs...
}
```

You can provide multiple [`ToolbarPlacement`](/documentation/SwiftUI/ToolbarPlacement) instances to customize
multiple bars at once.

```
TabView {
    NavigationView {
        ContentView()
            .toolbarBackground(
                .blue, for: .navigationBar, .tabBar)
            .toolbarColorScheme(
                .dark, for: .navigationBar, .tabBar)
    }
}
```

Note that the provided color scheme is only respected while a
background is visible in the requested bar. As the background becomes
visible, the bar transitions from the color scheme of the app to the
requested color scheme. You can ensure that the color scheme is always
respected by specifying that the background of the bar always be
visible.

```
NavigationView {
    ContentView()
        .toolbarBackground(.visible)
        .toolbarColorScheme(.dark)
}
```

Depending on the specified bars, the requested color scheme may not be
able to be fullfilled.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)