ToolbarRole

The purpose of content that populates the toolbar.

StructureiOS 16.0+macOS 13.0+tvOS 16.0+watchOS 9.0+ToolbarRole in SwiftUI

Declaration

React
type ToolbarRole = 'automatic' | 'browser' | 'editor' | 'navigationStack';
Swift
struct ToolbarRole

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

Type properties

Overview

A toolbar role provides a description of the purpose of content that populates the toolbar. The purpose of the content influences how a toolbar renders its content. For example, a ToolbarRole.browser will automatically leading align the title of a toolbar in iPadOS.

Provide this type to the View.toolbarRole(_:) modifier:

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

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

Used by

See also

More in Navigation.