GlassNavigationBar
| Identifier | glass-navigation-bar |
| Module | SPGlassNavigation |
| Kind | native-wrapper — a NavigationStack configured with .navigationTitle and .toolbar |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Navigation/GlassNavigationBarExample.swift |
Minimal usage
swift
GlassNavigationBar("Inbox") {
MessageList()
}Variants
| Variant | Use |
|---|---|
titleDisplay: .large |
Large title that collapses on scroll (iOS). |
titleDisplay: .inline |
Compact title, for detail pages. |
subtitle: |
Secondary line under the title (navigationSubtitle). |
leading: / trailing: |
Actions described by GlassToolbarAction values. |
.glassNavigationBar(...) modifier |
Configures the bar of a page pushed on an existing stack. |
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
title |
LocalizedStringKey |
— | Title of the page. |
subtitle |
LocalizedStringKey? |
nil |
Subtitle. |
titleDisplay |
GlassNavigationTitleDisplay |
.automatic |
.automatic, .inline or .large. |
path |
Binding<NavigationPath>? |
nil |
Navigation path when the host drives navigation. |
leading |
[GlassToolbarAction] |
[] |
Actions at the leading edge. One is shown; others go to a menu. |
trailing |
[GlassToolbarAction] |
[] |
Actions at the trailing edge. |
content |
@ViewBuilder |
— | Root page of the stack. |
GlassNavigationBarConfiguration carries the same values when the title is a Text built elsewhere.
States
The back button, its title and the swipe-back gesture are the system's. A disabled action is isEnabled: false. Trailing actions that do not fit move to a "More actions" menu: two stay on a compact width, four on a regular one, one at accessibility text sizes (GlassNavigationBarLayout.trailingCapacity).
Advanced example
swift
@State private var path = NavigationPath()
GlassNavigationBar("Projects", titleDisplay: .large, path: $path, trailing: [
GlassToolbarAction(id: "new", title: "New project", systemImage: "plus",
shortcut: KeyboardShortcut("n"), priority: .high) { create() },
GlassToolbarAction(id: "filter", title: "Filter", systemImage: "line.3.horizontal.decrease") { showFilter() },
]) {
ProjectList()
.navigationDestination(for: Project.ID.self) { id in
ProjectView(id: id)
.glassNavigationBar("Project", titleDisplay: .inline, trailing: [
GlassToolbarAction(id: "delete", title: "Delete", systemImage: "trash", role: .destructive) { delete(id) },
])
}
}Accessibility
- Every action has a title: it is the VoiceOver label, the tooltip on macOS and the menu title when the action overflows.
- With an accessibility text size on a compact width, a large title is shown inline so that it does not fill the screen, and only one trailing action stays in the bar.
- Bar buttons get the system's large content viewer at accessibility sizes.
- Keyboard shortcuts of the actions work whether the action is in the bar or in the menu.
Limits
- The bar, its glass and the back button cannot be restyled; the theme only supplies the tint.
titleDisplayhas no effect on macOS, which shows the title in the window toolbar.- Do not nest a
GlassNavigationBarinside another navigation stack; use the modifier on pushed pages. - Behaviour at accessibility sizes was verified through the layout functions and compilation, not on a running device.