GlassNavigationBar
NavigationStack with a title, toolbar actions and the system back button.
- System control
- iOS 26 · iPadOS 26 · macOS 26
- Version 1.1.0
glass-navigation-bar
Drawn by the system. GlassKit configures it and leaves the glass to the system.
CaptureInstallation
spglass add glass-navigation-barCopies the sources and their dependencies into your project. Set up the CLI.
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")
import SPGlassKit| 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
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
@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.
Example
import SwiftUI
import SPGlassKit
public struct GlassNavigationBarExample: GlassExample {
public static let componentID = "glass-navigation-bar"
@State private var notes = ["Quarterly review", "Trip to Lisbon", "A much longer note title that has to wrap or truncate gracefully"]
@State private var isFlagged = false
public init() {}
public var body: some View {
GlassNavigationBar(
"Notes",
subtitle: "\(notes.count) notes",
titleDisplay: .large,
leading: [
GlassToolbarAction(id: "sort", title: "Sort", systemImage: "arrow.up.arrow.down") { notes.sort() },
],
trailing: [
GlassToolbarAction(id: "new", title: "New note", systemImage: "square.and.pencil", shortcut: KeyboardShortcut("n"), priority: .high) {
notes.append("Untitled \(notes.count + 1)")
},
GlassToolbarAction(id: "shuffle", title: "Shuffle", systemImage: "shuffle") { notes.shuffle() },
GlassToolbarAction(id: "clear", title: "Delete all", systemImage: "trash", role: .destructive, isEnabled: !notes.isEmpty, priority: .low) {
notes.removeAll()
},
]
) {
List(notes, id: \.self) { note in
NavigationLink(note, value: note)
}
.overlay {
if notes.isEmpty { ContentUnavailableView("No notes", systemImage: "note.text") }
}
.navigationDestination(for: String.self) { note in
ScrollView {
Text(verbatim: note)
.font(.title3)
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
}
.glassNavigationBar(
"Note",
titleDisplay: .inline,
trailing: [
GlassToolbarAction(id: "flag", title: isFlagged ? "Remove flag" : "Flag", systemImage: isFlagged ? "flag.fill" : "flag") {
isFlagged.toggle()
},
]
)
}
}
}
}
#Preview("GlassNavigationBar") { GlassNavigationBarExample().glassTheme(.ocean) }
Registry entry
| Identifier | glass-navigation-bar |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-foundation, glass-toolbar |
| Frameworks | SwiftUI |
| Public symbols | GlassNavigationTitleDisplay, GlassNavigationBarConfiguration, GlassNavigationBar, GlassNavigationBarLayout |
| Licence | MIT |
| Manifest | manifest.json |
Files
Navigation/Navigation/GlassNavigationBar.swift9124 bytes · sha256 b91d9639817a…