ContentToolbarPlacement

A region of the interface that hosts its own toolbar content.

StructureiOS 18.4+macOS 15.4+tvOS 18.4+watchOS 11.4+visionOS 2.4+ContentToolbarPlacement in SwiftUI

Declaration

React
type ContentToolbarPlacement = 'tabViewSidebar';
Swift
struct ContentToolbarPlacement

Pass a literal, or build one with SwiftUI.ContentToolbarPlacement from import { SwiftUI } from 'swiftui-react-native'.

Type properties

  • 'tabViewSidebar'SwiftUI.ContentToolbarPlacement.tabViewSidebar

    The tab view sidebar. This is present on certain platforms when using the .sidebarAdaptable tab view style.

Overview

Some containers draw a bar that belongs to the container as a whole rather than to the view currently on screen, such as the sidebar of a TabView that uses the TabViewStyle.sidebarAdaptable style. Pass a value of this type to View.contentToolbar(for:content:) to put items in one of those bars.

The following example adds a button to the sidebar of a tab view, where it stays put as someone moves between tabs:

TabView {
    Tab("Lights", systemImage: "lightbulb") {
        LightsView()
    }

    Tab("Locks", systemImage: "lock") {
        LocksView()
    }
}
.tabViewStyle(.sidebarAdaptable)
.contentToolbar(for: .tabViewSidebar) {
    ToolbarItem {
        DisconnectDevicesButton()
    }
}

Each placement accepts only some ToolbarItemPlacement values. Check the documentation of the placement you use before you rely on a position.

From Apple’s SwiftUI documentation. Code samples there are Swift.

Used by

See also

More in Navigation.