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

# toolbar(_:for:)

Specifies the visibility of a bar managed by SwiftUI.

## Declaration

```swift
nonisolated func toolbar(_ visibility: Visibility, for bars: ToolbarPlacement...) -> some View

```

## Parameters

- `visibility`: The preferred visibility of the bar.
- `bars`: The bars to update the visibility of or doc://com.apple.SwiftUI/documentation/SwiftUI/ToolbarPlacement/automatic if empty.

## Discussion

Discussion The preferred visibility 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 examples shows a view that hides the navigation bar on iOS, or the window toolbar items on macOS. NavigationView {     ContentView()         .toolbar(.hidden) } To hide the entire titlebar on macOS, use this modifier with windowToolbar placement. NavigationView {     ContentView()         .toolbar(.hidden, for: .windowToolbar) } You can provide multiple ToolbarPlacement instances to hide multiple bars at once. TabView {     NavigationView {         ContentView()             .toolbar(                 .hidden, for: .navigationBar, .tabBar)     } } note: In macOS, if you provide ToolbarCommands to the scene of your app, this modifier disables the toolbar visibility command while the value of the modifier is not automatic. Depending on the specified bars, the requested visibility may not be able to be fulfilled.

## See Also

### Setting toolbar visibility

- [toolbarVisibility(_:for:)](swiftui/view/toolbarvisibility(_:for:).md)
- [toolbarBackgroundVisibility(_:for:)](swiftui/view/toolbarbackgroundvisibility(_:for:).md)
- [ToolbarPlacement](swiftui/toolbarplacement.md)
- [ContentToolbarPlacement](swiftui/contenttoolbarplacement.md)
