GlassToolbar
| Identifier | glass-toolbar |
| Module | SPGlassNavigation |
| Kind | native-wrapper — ToolbarContent made of ToolbarItemGroups with system placements |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Navigation/GlassToolbarExample.swift |
Minimal usage
swift
content.glassToolbar([
GlassToolbarGroup(id: "main", placement: .trailing, actions: [
GlassToolbarAction(id: "share", title: "Share", systemImage: "square.and.arrow.up") { share() },
]),
])GlassToolbar(groups) is the same thing as ToolbarContent, to combine with other items inside .toolbar { }.
Variants
| Placement | System placement |
|---|---|
.automatic |
.automatic |
.leading |
.topBarLeading (iOS), .navigation (macOS) |
.trailing |
.topBarTrailing (iOS), .primaryAction (macOS) |
.primary |
.primaryAction |
.secondary |
.secondaryAction — the system collects these in its own overflow menu |
.bottom |
.bottomBar (iOS), .automatic (macOS) |
.cancellation / .confirmation |
.cancellationAction / .confirmationAction |
Parameters
GlassToolbarAction
| Parameter | Type | Default | Meaning |
|---|---|---|---|
id |
String |
— | Stable identifier. |
title / verbatim / text |
LocalizedStringKey / StringProtocol / Text |
— | Label, tooltip and menu title. |
systemImage |
String |
— | SF Symbol shown in the bar. |
role |
ButtonRole? |
nil |
.destructive, .cancel. |
shortcut |
KeyboardShortcut? |
nil |
Keyboard shortcut. |
isEnabled |
Bool |
true |
Disabled state. |
priority |
GlassToolbarActionPriority |
.normal |
.low overflows first, .high last. |
action |
@MainActor () -> Void |
— | Called on activation. |
GlassToolbarGroup
| Parameter | Type | Default | Meaning |
|---|---|---|---|
id |
String |
— | Stable identifier. |
placement |
GlassToolbarPlacement |
.automatic |
Where the group goes. |
capacity |
Int? |
nil |
Controls shown before overflow. nil: two on a compact width or at accessibility text sizes, five otherwise. |
actions |
[GlassToolbarAction] |
— | Actions in order. |
States
Enabled and disabled per action. Overflow is decided by the pure function GlassToolbarLayout.split(_:capacity:): when everything fits, everything is visible; otherwise the "More actions" menu takes one place and the rest goes to the actions of highest priority, the earliest first among equals. Order is kept on both sides.
Advanced example
swift
.toolbar {
GlassToolbar([
GlassToolbarGroup(id: "edit", placement: .trailing, capacity: 3, actions: [
GlassToolbarAction(id: "share", title: "Share", systemImage: "square.and.arrow.up",
shortcut: KeyboardShortcut("s", modifiers: [.command, .shift]), priority: .high) { share() },
GlassToolbarAction(id: "duplicate", title: "Duplicate", systemImage: "plus.square.on.square",
shortcut: KeyboardShortcut("d")) { duplicate() },
GlassToolbarAction(id: "archive", title: "Archive", systemImage: "archivebox", priority: .low) { archive() },
GlassToolbarAction(id: "delete", title: "Delete", systemImage: "trash", role: .destructive, priority: .low) { delete() },
]),
GlassToolbarGroup(id: "export", placement: .secondary, actions: [exportPDF, print]),
])
ToolbarItem(placement: .principal) { DocumentTitle() }
}With a capacity of three, Share and Duplicate stay in the bar; Archive and Delete are in the menu.
Accessibility
- Each button is a
Label: the bar shows the symbol, VoiceOver reads the title, macOS shows it as a tooltip. - The overflow menu is labelled "More actions" (localised) and lists titles with symbols; the destructive role is conveyed by the system.
- Shortcuts are attached to the buttons themselves, in the bar or in the menu.
- At accessibility text sizes fewer controls are kept in the bar.
Limits
- The system may still rearrange or collapse items of its own accord; the capacity is an upper bound, not a promise.
- Capacity is a count of controls, not a measured width.
.bottomhas no bottom bar on macOS and falls back to the automatic placement.- That shortcuts of actions inside the overflow menu fire on every platform was not verified on a running device.