SP GlassKit1.1.0

GlassSidebar

NavigationSplitView sidebar with sections, selection, search and adaptive collapse.

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

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

GlassSidebar 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-sidebar

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-sidebar
ModuleSPGlassNavigation
Kindnative-wrapper — a NavigationSplitView whose sidebar is a system List with .searchable
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/Navigation/GlassSidebarExample.swift

Minimal usage

Swift
@State private var selection: String?

GlassSidebar("Mail", sections: [
    GlassSidebarSection(id: "boxes", title: "Mailboxes", items: [
        GlassSidebarItem(id: "inbox", title: "Inbox", systemImage: "tray", badge: 12),
        GlassSidebarItem(id: "sent", title: "Sent", systemImage: "paperplane"),
    ]),
], selection: $selection) { id in
    if let id { MailboxView(id: id) } else { Text("Select a mailbox") }
}

Variants

VariantUse
Section with title: nilRows without a header.
badge:Count at the trailing edge of a row; zero shows nothing.
keywords:Extra words the search matches (synonyms, translations).
isSearchable: falseNo search field.
columnVisibility:Collapse or show the sidebar from code.

Parameters

ParameterTypeDefaultMeaning
titleLocalizedStringKey—Title of the sidebar column.
sections[GlassSidebarSection<ID>]—Rows, grouped.
selectionBinding<ID?>—Selected row.
searchTextBinding<String>?nilSearch text when the host needs it; otherwise owned by the sidebar.
columnVisibilityBinding<NavigationSplitViewVisibility>?nilSidebar visibility when the host drives it.
isSearchableBooltrueAdds the system search field (placement: .sidebar).
searchPromptLocalizedStringKey?"Search"Placeholder of the search field.
detail(ID?) -> Detail—Detail column for the selection.

States

Selected row: selection. Searching: rows are filtered by GlassSidebarFilter.filter(_:query:); a search without result shows the system's ContentUnavailableView.search. Collapsed: on a compact width the system turns the split view into a stack and pushes the detail when a row is selected.

Advanced example

Swift
@State private var selection: Folder.ID?
@State private var query = ""
@State private var visibility: NavigationSplitViewVisibility = .all

GlassSidebar("Files", sections: model.sections, selection: $selection,
             searchText: $query, columnVisibility: $visibility, searchPrompt: "Search folders") { id in
    FolderView(id: id)
        .toolbar {
            Button("Focus", systemImage: "rectangle.expand.vertical") { visibility = .detailOnly }
        }
}
.onChange(of: query) { model.logRecentSearch($1) }

The filter is public and pure, so the host can reuse it:

Swift
GlassSidebarFilter.filter(sections, query: "evenements")   // matches "Événements"

Accessibility

  • Rows are system list rows: selection, headers and badges are announced by the system; the list is fully keyboard navigable.
  • Symbols are decorative; the title is always present.
  • Search ignores case, accents and character width, and matches every word of the query in any order.
  • Row titles wrap at large text sizes.

Limits

  • Row and section titles are Strings supplied already localised, because the search needs their text.
  • One level of sections; no nested outline.
  • A section whose title matches the query keeps all its rows.
  • Collapse behaviour and the search field placement were compiled for both platforms but not exercised on a running device here.

Example

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

public struct GlassSidebarExample: GlassExample {
    public static let componentID = "glass-sidebar"
    @State private var selection: String? = "inbox"
    @State private var columnVisibility: NavigationSplitViewVisibility = .automatic

    public init() {}

    private let sections: [GlassSidebarSection<String>] = [
        GlassSidebarSection(id: "mailboxes", title: "Mailboxes", items: [
            GlassSidebarItem(id: "inbox", title: "Inbox", systemImage: "tray", badge: 12, keywords: ["unread"]),
            GlassSidebarItem(id: "drafts", title: "Drafts", systemImage: "doc", badge: 2),
            GlassSidebarItem(id: "sent", title: "Sent", systemImage: "paperplane"),
            GlassSidebarItem(id: "archive", title: "Archive", systemImage: "archivebox"),
        ]),
        GlassSidebarSection(id: "labels", title: "Labels", items: [
            GlassSidebarItem(id: "travel", title: "Voyages et séjours", systemImage: "airplane", keywords: ["travel", "trips"]),
            GlassSidebarItem(id: "receipts", title: "Reçus", systemImage: "receipt", keywords: ["receipts"]),
            GlassSidebarItem(id: "long", title: "A label with a deliberately long name to check wrapping", systemImage: "tag"),
        ]),
    ]

    public var body: some View {
        GlassSidebar("Mail", sections: sections, selection: $selection, columnVisibility: $columnVisibility, searchPrompt: "Search mailboxes") { id in
            if let id {
                VStack(spacing: 12) {
                    Text(verbatim: title(of: id)).font(.title2)
                    Button(columnVisibility == .detailOnly ? "Show sidebar" : "Hide sidebar") {
                        columnVisibility = columnVisibility == .detailOnly ? .all : .detailOnly
                    }
                }
                .padding()
                .navigationTitle(Text(verbatim: title(of: id)))
            } else {
                ContentUnavailableView("Select a mailbox", systemImage: "sidebar.left")
            }
        }
    }

    private func title(of id: String) -> String {
        sections.flatMap(\.items).first { $0.id == id }?.title ?? id
    }
}

#Preview("GlassSidebar") { GlassSidebarExample() }

Registry entry

Identifierglass-sidebar
Version1.1.0
Depends onglass-foundation
FrameworksSwiftUI
Public symbolsGlassSidebarItem, GlassSidebarSection, GlassSidebarFilter, GlassSidebar
LicenceMIT
Manifestmanifest.json

Files