toolbarRole

Configures the semantic role for the content populating the toolbar.

View ModifieriOS 16.0+macOS 13.0+tvOS 16.0+watchOS 9.0+toolbarRole(_:) in SwiftUI

Declaration

React
compose().toolbarRole(role: SwiftUI.ToolbarRole)
Swift
nonisolated func toolbarRole(_ role: ToolbarRole) -> some View

Parameters

Discussion

Use this modifier to configure the semantic role for content populating your app's toolbar. SwiftUI uses this role when rendering the content of your app's toolbar.

ContentView()
    .navigationTitle("Browser")
    .toolbarRole(.browser)
    .toolbar {
        ToolbarItem(placement: .primaryAction) {
            AddButton()
        }
     }

See also

More in Navigation.