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.
CaptureInstallation
spglass add glass-model-pickerCopies 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-model-picker |
|---|---|
| Module | SPGlassAI |
| Kind | native-wrapper — the system draws the Menu and its rows; the optional list style is drawn by GlassKit on opaque surfaces |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/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
@State private var modelID: String? = "small"
GlassModelPicker(models: models, selection: $modelID)Variants
| Availability | Row |
|---|---|
.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.
| Style | Use |
|---|---|
.menu (default) | A compact chip that opens the system menu. For a toolbar or the accessory slot of a prompt bar. |
.list | The 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
| Parameter | Type | Default | Meaning |
|---|---|---|---|
title | LocalizedStringKey? | "Model" | Accessibility label, and visible title when nothing is selected. |
models | [GlassModelInfo] | — | id, name, provider, capabilities, availability. Any order. |
selection | Binding<String?> | — | Identifier of the selected model. |
style | GlassModelPickerStyle | .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
Toggleinside 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
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
selectionexists inmodels; 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
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
| Identifier | glass-model-picker |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-foundation |
| Frameworks | SwiftUI |
| Public symbols | GlassModelCapabilities, Descriptor, GlassModelAvailability, GlassModelInfo, GlassModelGroup, GlassModelCatalog, GlassModelPickerStyle, GlassModelPicker |
| Licence | MIT |
| Manifest | manifest.json |
Files
AI/AI/GlassModelPicker.swift19542 bytes · sha256 699b2756d9c4…