<!--
{
  "availability" : [
    "iOS: 18.4.0 -",
    "iPadOS: 18.4.0 -",
    "macCatalyst: 18.4.0 -",
    "macOS: 15.4.0 -",
    "tvOS: 18.4.0 -",
    "visionOS: 2.4.0 -",
    "watchOS: 11.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/contentToolbar(for:content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE14contentToolbar3for0D0QrAA07ContentE9PlacementV_qd__yXEtAaBRd__lF::OverloadGroup"
  },
  "title" : "contentToolbar(for:content:)"
}
-->

# contentToolbar(for:content:)

Populates the toolbar of the specified content view type with
the views you provide.

```
nonisolated func contentToolbar<Content>(for placement: ContentToolbarPlacement, @ContentBuilder content: () -> Content) -> some View where Content : View
```

## Parameters

`content`

The views representing the content of the toolbar.

## Discussion

Use this modifier to add toolbar content that remains consistent
regardless of the content view.

Unlike the toolbar modifier, which configures the toolbar of the
modified view’s container, the `contentToolbar` modifier configures the
toolbar within the modified view’s content instead. This means that the
`contentToolbar` modifier should generally be applied directly to a
container view, instead of to the content within a container view. For
example, to configure the toolbar of tab view’s sidebar, apply the
`contentToolbar` modifier to the `TabView` itself, not to any of the
tabs within the `TabView`.

The example below adds a button to the tab view sidebar.

```
TabView {
    Tab("Home", systemImage: "house") {
        HomeView()
    }

    Tab("Alerts", systemImage: "bell") {
        AlertsView()
    }

    TabSection("Categories") {
        Tab("Climate", systemImage: "fan") {
            ClimateView()
        }

        Tab("Lights", systemImage: "lightbulb") {
            LightsView()
        }
    }
}
.tabViewStyle(.sidebarAdaptable)
.contentToolbar(for: .tabViewSidebar) {
    DisconnectDevicesButton()
}
```

---

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)