SP GlassKit1.1.0

GlassToolbar

Groups of toolbar actions with system placements, overflow and keyboard shortcuts.

  • System control
  • iOS 26 · iPadOS 26 · macOS 26
  • Version 1.1.0
  • glass-toolbar

Drawn by the system. GlassKit configures it and leaves the glass to the system.

GlassToolbar running in SP Glass Studio.Capture
Capture of the component running in SP Glass Studio on the iOS 26.5 simulator. Liquid Glass is rendered by the system; this is an image, not a live preview.

Installation

spglass add glass-toolbar

Copies the sources and their dependencies into your project. Set up the CLI.

Swift
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")

import SPGlassKit
Identifierglass-toolbar
ModuleSPGlassNavigation
Kindnative-wrapper — ToolbarContent made of ToolbarItemGroups with system placements
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/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

PlacementSystem 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

ParameterTypeDefaultMeaning
idString—Stable identifier.
title / verbatim / textLocalizedStringKey / StringProtocol / Text—Label, tooltip and menu title.
systemImageString—SF Symbol shown in the bar.
roleButtonRole?nil.destructive, .cancel.
shortcutKeyboardShortcut?nilKeyboard shortcut.
isEnabledBooltrueDisabled state.
priorityGlassToolbarActionPriority.normal.low overflows first, .high last.
action@MainActor () -> Void—Called on activation.

GlassToolbarGroup

ParameterTypeDefaultMeaning
idString—Stable identifier.
placementGlassToolbarPlacement.automaticWhere the group goes.
capacityInt?nilControls 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.
  • .bottom has 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.

Example

Complete example (compiled with the package)
import SwiftUI
import SPGlassKit

public struct GlassToolbarExample: GlassExample {
    public static let componentID = "glass-toolbar"
    @State private var log = ["Nothing yet"]
    @State private var isPinned = false

    public init() {}

    private func record(_ entry: String) {
        log.insert(entry, at: 0)
    }

    private var groups: [GlassToolbarGroup] {
        [
            GlassToolbarGroup(id: "document", placement: .trailing, capacity: 3, actions: [
                GlassToolbarAction(id: "share", title: "Share", systemImage: "square.and.arrow.up", shortcut: KeyboardShortcut("s", modifiers: [.command, .shift]), priority: .high) { record("Shared") },
                GlassToolbarAction(id: "pin", title: isPinned ? "Unpin" : "Pin", systemImage: isPinned ? "pin.fill" : "pin") {
                    isPinned.toggle()
                    record(isPinned ? "Pinned" : "Unpinned")
                },
                GlassToolbarAction(id: "duplicate", title: "Duplicate", systemImage: "plus.square.on.square", shortcut: KeyboardShortcut("d")) { record("Duplicated") },
                GlassToolbarAction(id: "archive", title: "Archive", systemImage: "archivebox", isEnabled: log.count > 1, priority: .low) { record("Archived") },
                GlassToolbarAction(id: "delete", title: "Delete", systemImage: "trash", role: .destructive, priority: .low) { log = ["Nothing yet"] },
            ]),
            GlassToolbarGroup(id: "export", placement: .secondary, actions: [
                GlassToolbarAction(id: "pdf", title: "Export as PDF", systemImage: "doc.richtext") { record("Exported as PDF") },
                GlassToolbarAction(id: "print", title: "Print", systemImage: "printer", shortcut: KeyboardShortcut("p")) { record("Printed") },
            ]),
            GlassToolbarGroup(id: "format", placement: .bottom, actions: [
                GlassToolbarAction(id: "bold", title: "Bold", systemImage: "bold", shortcut: KeyboardShortcut("b")) { record("Bold") },
                GlassToolbarAction(id: "italic", title: "Italic", systemImage: "italic", shortcut: KeyboardShortcut("i")) { record("Italic") },
            ]),
        ]
    }

    public var body: some View {
        NavigationStack {
            List(Array(log.enumerated()), id: \.offset) { _, entry in
                Text(verbatim: entry)
            }
            .navigationTitle("Document")
            .glassToolbar(groups)
        }
    }
}

#Preview("GlassToolbar") { GlassToolbarExample() }

Registry entry

Identifierglass-toolbar
Version1.1.0
Depends onglass-foundation
FrameworksSwiftUI
Public symbolsGlassToolbarPlacement, GlassToolbarGroup, GlassToolbar, GlassToolbarActionPriority, GlassToolbarAction, GlassToolbarLayout, Split
LicenceMIT
Manifestmanifest.json

Files