GlassBreadcrumb
Typed path with truncation, an overflow menu and keyboard navigation.
- Custom glass
- iOS 26 · iPadOS 26 · macOS 26
- Version 1.1.0
glass-breadcrumb
Draws its own Liquid Glass surface, with an opaque form when Reduce Transparency is on.
CaptureInstallation
spglass add glass-breadcrumbCopies 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-breadcrumb |
|---|---|
| Module | SPGlassNavigation |
| Kind | custom-glass — a navigation bar drawn with glassSurface(_:in:), opaque with Reduce Transparency |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Navigation/GlassBreadcrumbExample.swift |
Minimal usage
GlassBreadcrumb([
GlassBreadcrumbItem(id: "root", title: "Home", systemImage: "house"),
GlassBreadcrumbItem(id: "docs", title: "Documents"),
GlassBreadcrumbItem(id: "2026", title: "2026"),
]) { id in
navigate(to: id)
}Variants
| Variant | Use |
|---|---|
maxVisibleItems: 4 (default) | Root, overflow menu, then the three levels closest to the current location. |
maxVisibleItems: 2 | Root, overflow menu, current location. |
maxVisibleItems: 1 | Overflow menu and current location only. |
systemImage: | A symbol before the title of a level. |
When the bar is narrower than its content, it shows fewer levels (down to one) before it truncates any title.
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
items | [GlassBreadcrumbItem<ID>] | — | Path from the root to the current location. An empty path draws nothing. |
maxVisibleItems | Int | 4 | Largest number of levels shown at once. |
onSelect | @MainActor (ID) -> Void | — | Called with the identifier of the activated level, visible or in the menu. |
States
The last item is the current location: stronger text, the selected trait and the accessibility value "Current location". The other levels are plain buttons. Hidden levels live in a menu labelled with their number ("3 hidden levels"). The layout is the pure type GlassBreadcrumbLayout(count:maxVisible:).
Advanced example
@State private var path: [Folder]
GlassBreadcrumb(path.map { GlassBreadcrumbItem(id: $0.id, title: $0.name) }, maxVisibleItems: 3) { id in
if let index = path.firstIndex(where: { $0.id == id }) {
path.removeSubrange((index + 1)...)
}
}
.safeAreaPadding(.horizontal)Accessibility
- The bar is a container labelled "Breadcrumb"; each level is a button whose label is its title.
- The current location is exposed by a trait and a value, not only by its weight and colour.
- Separators are hidden from assistive technologies.
- Every level and the menu are reachable with the keyboard (Tab or Full Keyboard Access) and have the platform's minimum hit target.
- Titles use theme fonts and follow Dynamic Type; a single remaining level truncates in the middle.
Limits
- One glass surface for the whole bar; levels are not individual glass surfaces.
- The bar is never tinted, whatever the theme's glass tint: it carries text in the theme's text colours, which a tinted glass (Aurora, Neon) made illegible in 1.0.
- Activating the current location also calls
onSelect; ignore it if it means nothing in your application. - The path is always written from the root; in right-to-left languages the row is mirrored by the system.
- Very long paths rely on the overflow menu; the bar does not scroll.
- Visual result and keyboard traversal were not checked on a running device here.
Example
import SwiftUI
import SPGlassKit
public struct GlassBreadcrumbExample: GlassExample {
public static let componentID = "glass-breadcrumb"
private static let fullPath: [GlassBreadcrumbItem<Int>] = [
GlassBreadcrumbItem(id: 0, title: "Home", systemImage: "house"),
GlassBreadcrumbItem(id: 1, title: "Projects"),
GlassBreadcrumbItem(id: 2, title: "2026"),
GlassBreadcrumbItem(id: 3, title: "Client workshop — été"),
GlassBreadcrumbItem(id: 4, title: "Photos"),
GlassBreadcrumbItem(id: 5, title: "Selected 📷"),
]
@State private var depth = 6
public init() {}
private var path: [GlassBreadcrumbItem<Int>] { Array(Self.fullPath.prefix(depth)) }
public var body: some View {
VStack(alignment: .leading, spacing: 24) {
GlassBreadcrumb(path) { id in depth = id + 1 }
GlassBreadcrumb(path, maxVisibleItems: 2) { id in depth = id + 1 }
GlassBreadcrumb(Array(Self.fullPath.prefix(1))) { _ in }
Text("Current: \(path.last?.title ?? "—")")
.font(.callout)
.foregroundStyle(.secondary)
Button("Go deeper") { depth = min(depth + 1, Self.fullPath.count) }
.disabled(depth == Self.fullPath.count)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
}
}
#Preview("GlassBreadcrumb") { GlassBreadcrumbExample().glassTheme(.emerald) }
Registry entry
| Identifier | glass-breadcrumb |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-foundation |
| Frameworks | SwiftUI |
| Public symbols | GlassBreadcrumbItem, GlassBreadcrumbLayout, GlassBreadcrumb |
| Licence | MIT |
| Manifest | manifest.json |
Files
Navigation/Navigation/GlassBreadcrumb.swift8587 bytes · sha256 6810fd968b4f…