Contents

ToolbarItemVisibilityPriority

A value that defines the visibility priority of a toolbar item.

Declaration

struct ToolbarItemVisibilityPriority

Overview

When a toolbar runs out of space, it moves items into an overflow menu. Visibility priority controls the order in which that happens: items with a lower priority move first, keeping higher-priority items visible longer as the window shrinks.

Use values of this type with the visibilityPriority(_:) modifier. For example, to keep a share button visible longer than an archive button:

struct RootView: View {
    var body: some View {
        ContentView()
            .toolbar {
                ToolbarItem {
                    SecondaryControl()
                }
                ToolbarItem {
                    PrimaryControl()
                }
                .visibilityPriority(.high)
            }
    }
}

Topics

Getting system priorities

Creating custom priorities

See Also

Controlling item visibility