---
title: "toolbarBackground(_:for:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/toolbarbackground(_:for:)"
---

# toolbarBackground(_:for:)

Specifies the preferred shape style of the background of a bar managed by SwiftUI.

## Declaration

```swift
nonisolated func toolbarBackground<S>(_ style: S, for bars: ToolbarPlacement...) -> some View where S : ShapeStyle

```

## Parameters

- `style`: The style to display as the background of the bar.
- `bars`: The bars to use the style for or doc://com.apple.SwiftUI/documentation/SwiftUI/ToolbarPlacement/automatic if empty.

## Discussion

Discussion The preferred style flows up to the nearest container that renders a bar. This could be a NavigationView or TabView in iOS, or the root view of a WindowGroup in macOS. This example shows a view that renders the navigation bar with a blue background and dark color scheme. NavigationView {     ContentView()         .toolbarBackground(.white)         .toolbarColorScheme(.dark) } You can provide multiple ToolbarPlacement instances to customize multiple bars at once. TabView {     NavigationView {         ContentView()             .toolbarBackground(                 .blue, for: .navigationBar, .tabBar)             .toolbarColorScheme(                 .dark, for: .navigationBar, .tabBar)     } } When used within a TabView, the specified style will be preferred while the tab is currently active. You can use a Group to specify the same preferred background for every tab. TabView {     Group {         MainView()         SettingsView()     }     .toolbarBackground(.blue, for: .tabBar) } Depending on the specified bars, the requested style may not be able to be fullfilled.

## See Also

### Styling a toolbar

- [toolbarColorScheme(_:for:)](swiftui/view/toolbarcolorscheme(_:for:).md)
- [toolbarForegroundStyle(_:for:)](swiftui/view/toolbarforegroundstyle(_:for:).md)
- [windowToolbarStyle(_:)](swiftui/scene/windowtoolbarstyle(_:).md)
- [WindowToolbarStyle](swiftui/windowtoolbarstyle.md)
- [toolbarLabelStyle](swiftui/environmentvalues/toolbarlabelstyle.md)
- [ToolbarLabelStyle](swiftui/toolbarlabelstyle.md)
- [SpacerSizing](swiftui/spacersizing.md)
