Contents

ToolbarRole

The purpose of content that populates the toolbar.

Declaration

struct ToolbarRole

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 browser will automatically leading align the title of a toolbar in iPadOS.

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

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

Topics

Behavior-specific roles

Automatic roles

See Also

Specifying the role of toolbar content