SP GlassKit1.1.0

GlassModelPicker

Picker over an injected list of models with capabilities and local or remote state.

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

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

GlassModelPicker 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-model-picker

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-model-picker
ModuleSPGlassAI
Kindnative-wrapper — the system draws the Menu and its rows; the optional list style is drawn by GlassKit on opaque surfaces
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/AI/GlassModelPickerExample.swift

UI only: the list of models and their states are supplied by the host. The picker downloads nothing and contacts no provider.

Minimal usage

Swift
@State private var modelID: String? = "small"

GlassModelPicker(models: models, selection: $modelID)

Variants

AvailabilityRow
.local"On device · Text, Vision"
.remote"Remote · Text, Tools"
.unavailable(reason:)Disabled, "Unavailable · Not downloaded"

Models are grouped in sections by provider. The menu's label is the selected model's name with a symbol for where it runs, or the title when nothing is selected.

StyleUse
.menu (default)A compact chip that opens the system menu. For a toolbar or the accessory slot of a prompt bar.
.listThe models as rows, grouped by provider under a small heading: name, a marker saying where the model runs (symbol and word), one chip per capability, a checkmark on the selected row. Unavailable models are dimmed and show their reason. For a settings screen or a sheet.

Parameters

ParameterTypeDefaultMeaning
titleLocalizedStringKey?"Model"Accessibility label, and visible title when nothing is selected.
models[GlassModelInfo]—id, name, provider, capabilities, availability. Any order.
selectionBinding<String?>—Identifier of the selected model.
styleGlassModelPickerStyle.menu.menu or .list.

GlassModelCapabilities is an option set: .text, .vision, .tools, .reasoning, .audio, .code. Each has a localised name and a symbol (descriptors) for hosts that draw their own summary.

States

  • Selected: the row carries the system checkmark (each row is a Toggle inside the menu).
  • Unavailable: the row is disabled and gives the reason in words.
  • No selection: the label shows the title.
  • Empty list: the menu is disabled.

Sorting and grouping are GlassModelCatalog.grouped(_:): providers alphabetically; inside a provider, selectable models first, then by name with numeric-aware comparison; a repeated identifier keeps its first occurrence.

Advanced example

Swift
struct ModelToolbarItem: ToolbarContent {
    let registry: ModelRegistry                 // host type
    @Binding var selection: String?

    var body: some ToolbarContent {
        ToolbarItem(placement: .principal) {
            GlassModelPicker("Model", models: registry.models.map { model in
                GlassModelInfo(
                    id: model.id,
                    name: model.displayName,
                    provider: model.vendor,
                    capabilities: model.supportsImages ? [.text, .vision] : [.text],
                    availability: model.isDownloaded ? .local : .unavailable(reason: "Not downloaded")
                )
            }, selection: $selection)
        }
    }
}

Accessibility

  • The menu is labelled with the title; its value is the selected model's name, where it runs and its capabilities.
  • Capabilities and availability are written in words in every row; symbols are never the only carrier.
  • Unavailable rows are disabled by the system and state the reason.
  • Everything else (keyboard navigation, VoiceOver, Dynamic Type) is the system menu's behaviour.

Limits

  • How a second line of text is displayed in a menu row is decided by the platform; the text is always available to assistive technologies.
  • The picker does not validate that selection exists in models; an unknown identifier shows the title.
  • No search field: for long catalogues present a searchable list in a sheet instead.
  • The rendering of the menu was not inspected in a running application during verification; grouping, sorting and wording are unit-tested.

Example

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

public struct GlassModelPickerExample: GlassExample {
    public static let componentID = "glass-model-picker"

    /// Fictitious models and providers.
    private let models = [
        GlassModelInfo(id: "sample-nano", name: "Sample Nano", provider: "On this device (sample)", capabilities: [.text], availability: .local),
        GlassModelInfo(id: "sample-vision", name: "Sample Vision", provider: "On this device (sample)", capabilities: [.text, .vision], availability: .unavailable(reason: "Not downloaded")),
        GlassModelInfo(id: "sample-large", name: "Sample Large", provider: "Example Cloud (sample)", capabilities: [.text, .vision, .tools, .reasoning], availability: .remote),
        GlassModelInfo(id: "sample-code", name: "Sample Code", provider: "Example Cloud (sample)", capabilities: [.text, .code, .tools], availability: .remote),
        GlassModelInfo(id: "sample-voice", name: "Sample Voice", provider: "Example Cloud (sample)", capabilities: [.audio], availability: .unavailable(reason: "Sign-in required")),
    ]
    @State private var selection: String? = "sample-nano"
    @State private var emptySelection: String?

    public init() {}

    public var body: some View {
        Form {
            Section("Sample data · fictitious models") {
                LabeledContent("Model") {
                    GlassModelPicker(models: models, selection: $selection)
                }
                if let model = GlassModelCatalog.model(withID: selection, in: models) {
                    LabeledContent("Runs", value: GlassModelCatalog.subtitle(for: model))
                    HStack {
                        ForEach(model.capabilities.descriptors, id: \.self) { capability in
                            Label(capability.label, systemImage: capability.symbolName)
                                .font(.caption)
                        }
                    }
                }
            }
            Section("As a list") {
                GlassModelPicker(models: models, selection: $selection, style: .list)
                    .listRowInsets(EdgeInsets())
                    .listRowBackground(Color.clear)
            }
            Section("No selection yet") {
                GlassModelPicker("Choose a sample model", models: models, selection: $emptySelection)
            }
            Section("Empty list") {
                GlassModelPicker(models: [], selection: .constant(nil))
            }
        }
        .formStyle(.grouped)
    }
}

#Preview("GlassModelPicker") { GlassModelPickerExample().glassTheme(.ocean) }

Registry entry

Identifierglass-model-picker
Version1.1.0
Depends onglass-foundation
FrameworksSwiftUI
Public symbolsGlassModelCapabilities, Descriptor, GlassModelAvailability, GlassModelInfo, GlassModelGroup, GlassModelCatalog, GlassModelPickerStyle, GlassModelPicker
LicenceMIT
Manifestmanifest.json

Files