Contents

windowToolbarLabelStyle(_:)

Sets the label style of items in a toolbar and enables user customization.

Declaration

nonisolated func windowToolbarLabelStyle(_ toolbarLabelStyle: Binding<ToolbarLabelStyle>) -> some Scene

Parameters

  • toolbarLabelStyle:

    The label style to apply.

Discussion

Use this modifier to bind a ToolbarLabelStyle to AppStorage. The toolbar will default to the label style specified but will also be user configurable.

    @main
    struct MyApp: App {
        @AppStorage("ToolbarLabelStyle")
        private var labelStyle: ToolbarLabelStyle = .iconOnly

        var body: some Scene {
            WindowGroup {
                ContentView()
                    .toolbar(id: "browserToolbar") {
                        ...
                    }
            }
            .windowToolbarLabelStyle($labelStyle)
        }
    }

See Also

Styling the associated toolbar