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

# toolbar(_:for:)

Specifies the visibility of a bar managed by SwiftUI.

```
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
[`automatic`](/documentation/SwiftUI/ToolbarPlacement/automatic) if empty.

## Discussion

The preferred visibility 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.

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`](/documentation/SwiftUI/ToolbarPlacement/windowToolbar) placement.

```
NavigationView {
    ContentView()
        .toolbar(.hidden, for: .windowToolbar)
}
```

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

```
TabView {
    NavigationView {
        ContentView()
            .toolbar(
                .hidden, for: .navigationBar, .tabBar)
    }
}
```

> Note: In macOS, if you provide ``doc://com.apple.SwiftUI/documentation/SwiftUI/ToolbarCommands`` to the scene
> of your app, this modifier disables the toolbar visibility command
> while the value of the modifier is not ``doc://com.apple.SwiftUI/documentation/SwiftUI/ToolbarPlacement/automatic``.

Depending on the specified bars, the requested visibility may not be
able to be fulfilled.

---

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)