SP GlassKit1.1.0

GlassPicker

Generic picker over Hashable options, as a menu or a wheel depending on the platform.

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

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

GlassPicker 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-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-picker
ModuleSPGlassForms
Kindnative-wrapper — the system Picker with a platform-appropriate style
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/Selection/GlassPickerExample.swift

Minimal usage

Swift
@State private var currency = "CAD"

GlassPicker("Currency", selection: $currency, options: ["CAD", "EUR", "USD"])

Variants

presentationiOS and iPadOSmacOS
.menu (default)Pop-up menuPop-up button
.wheelWheelPop-up button (no wheel on macOS)
.inlineInline list of optionsRadio buttons

Options can be named three ways: by themselves (CustomStringConvertible, as above), by a closure or key path (title: \.name), or by a view builder for rows with a symbol.

Parameters

ParameterTypeDefaultMeaning
titleLocalizedStringKey—Label of the picker.
selectionBinding<Option>—Selected option. Option is any Hashable type.
options[Option]—Options in order.
presentationGlassPickerPresentation.menuMenu, wheel or inline.
title:(Option) -> String—Name of an option.
optionLabel@ViewBuilder (Option) -> View—Custom label of an option.

States

The selected option, the open menu, focus and the disabled state (.disabled(_:)) are drawn by the system.

Advanced example

Swift
struct Plan: Hashable { let name: String; let symbol: String }

GlassPicker("Plan", selection: $plan, options: plans) { plan in
    Label(plan.name, systemImage: plan.symbol)
}

GlassPicker("Reminder", selection: $hour, options: Array(6...22), presentation: .wheel, title: { hour in
    "\(hour.formatted(.number.precision(.integerLength(2)))):00"
})

GlassPickerPresentation.wheel.resolved(for: .macOS) returns .menu: the mapping is a pure function.

Accessibility

  • The picker is a system control: label, current value, the list of options and keyboard navigation come from the system.
  • Option labels built with Label keep their text for VoiceOver.
  • Long option names wrap in the inline presentation and are shown in full in menus.

Limits

  • options must contain the current selection, as with any Picker; otherwise nothing appears selected.
  • On iOS and iPadOS the menu presentation is a row: the title on the leading side, the system menu button on the trailing side (since 1.1; the system picker alone shows only its value outside a Form).
  • Options must be unique (Hashable identity is used).
  • The wheel exists only on iOS and iPadOS, radio buttons only on macOS.
  • Single selection only.

Example

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

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

    struct Plan: Hashable {
        let name: String
        let symbol: String
    }

    private static let plans = [
        Plan(name: "Starter", symbol: "leaf"),
        Plan(name: "Team", symbol: "person.3"),
        Plan(name: "Enterprise with a long name", symbol: "building.2"),
    ]

    @State private var plan = GlassPickerExample.plans[0]
    @State private var currency = "CAD"
    @State private var hour = 9
    @State private var priority = "Normal"

    public init() {}

    public var body: some View {
        Form {
            GlassPicker("Plan", selection: $plan, options: Self.plans) { plan in
                Label(plan.name, systemImage: plan.symbol)
            }
            GlassPicker("Currency", selection: $currency, options: ["CAD", "EUR", "JPY", "USD"])
            GlassPicker("Reminder hour", selection: $hour, options: Array(6...22), presentation: .wheel) { hour in
                "\(hour.formatted(.number.precision(.integerLength(2)))):00"
            }
            GlassPicker("Priority", selection: $priority, options: ["Low", "Normal", "High"], presentation: .inline)
            GlassPicker("Region", selection: .constant("Canada"), options: ["Canada"])
                .disabled(true)
        }
    }
}

#Preview("GlassPicker") { GlassPickerExample() }

Registry entry

Identifierglass-picker
Version1.1.0
Depends onglass-foundation
FrameworksSwiftUI
Public symbolsGlassPickerPresentation, Resolved, GlassPicker
LicenceMIT
Manifestmanifest.json

Files