Prefer Vertical Toolbar Items
A compression behavior that prioritizes keeping toolbar items visible over other elements, such as tabs. By default, tabs are prioritized.
Platform Compatibility
Tags
SwiftUI Code
TabView {
Tab("A", systemImage: "a.square") {
NavigationStack {
Text("FooBar")
.toolbar {
ToolbarItem {
Button("1", systemImage: "1.circle", action: action)
}
ToolbarItem {
Button("2", systemImage: "2.circle", action: action)
}
ToolbarItem {
Button("3", systemImage: "3.circle", action: action)
}
ToolbarItem {
Button("4", systemImage: "4.circle", action: action)
}
ToolbarItem {
Button("5", systemImage: "5.circle", action: action)
}
}
.toolbarVerticalCompressionBehavior(.prefersToolbarItems)
}
}
Tab("B", systemImage: "b.square") {}
Tab("C", systemImage: "c.square") {}
Tab("D", systemImage: "d.square") {}
Tab("E", systemImage: "e.square") {}
Tab("F", systemImage: "f.square") {}
}Found an issue or have a suggestion?
More Toolbars Components
View allToolbar Overflow Menu
The overflow menu of a toolbar. An overflow menu represents actions that are always placed in the toolbar’s overflow menu, regardless of the toolbar mode, platform, or customizability.
Pinned Toolbar Item Placement
A placement that pins the item to the trailing edge of the toolbar.
ToolbarItem Shared Background Visibility
Controls the visibility of the glass background effect on items in the toolbar. In certain contexts, such as the navigation bar on iOS and the window toolbar on macOS, toolbar items will be given a glass background effect that is shared with other items in the same logical grouping
Explore Other Components
Browse allHidden List Section Separator
Sets whether to hide the separator associated with a list section.
Fitted Sheet Sizing
Sets the sizing of the containing presentation. This does not have any effect on smaller devices like iPhone and Apple Watch. On macOS, fitted is the default.
Custom List Section Spacing
Sets the spacing between adjacent sections in a List to a custom value.
CircularGaugeStyle
A gauge style that displays an open ring with a marker that appears at a point along the ring to indicate the gauge’s current value