Repository Public MIT
1# GlassPicker23| | |4|---|---|5| Identifier | `glass-picker` |6| Module | `SPGlassForms` |7| Kind | `native-wrapper` — the system `Picker` with a platform-appropriate style |8| Platforms | iOS 26, iPadOS 26, macOS 26 |9| Example | `Examples/Gallery/Selection/GlassPickerExample.swift` |1011## Minimal usage1213```swift14@State private var currency = "CAD"1516GlassPicker("Currency", selection: $currency, options: ["CAD", "EUR", "USD"])17```1819## Variants2021| `presentation` | iOS and iPadOS | macOS |22|---|---|---|23| `.menu` (default) | Pop-up menu | Pop-up button |24| `.wheel` | Wheel | Pop-up button (no wheel on macOS) |25| `.inline` | Inline list of options | Radio buttons |2627Options 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.2829## Parameters3031| Parameter | Type | Default | Meaning |32|---|---|---|---|33| `title` | `LocalizedStringKey` | — | Label of the picker. |34| `selection` | `Binding<Option>` | — | Selected option. `Option` is any `Hashable` type. |35| `options` | `[Option]` | — | Options in order. |36| `presentation` | `GlassPickerPresentation` | `.menu` | Menu, wheel or inline. |37| `title:` | `(Option) -> String` | — | Name of an option. |38| `optionLabel` | `@ViewBuilder (Option) -> View` | — | Custom label of an option. |3940## States4142The selected option, the open menu, focus and the disabled state (`.disabled(_:)`) are drawn by the system.4344## Advanced example4546```swift47struct Plan: Hashable { let name: String; let symbol: String }4849GlassPicker("Plan", selection: $plan, options: plans) { plan in50 Label(plan.name, systemImage: plan.symbol)51}5253GlassPicker("Reminder", selection: $hour, options: Array(6...22), presentation: .wheel, title: { hour in54 "\(hour.formatted(.number.precision(.integerLength(2)))):00"55})56```5758`GlassPickerPresentation.wheel.resolved(for: .macOS)` returns `.menu`: the mapping is a pure function.5960## Accessibility6162- The picker is a system control: label, current value, the list of options and keyboard navigation come from the system.63- Option labels built with `Label` keep their text for VoiceOver.64- Long option names wrap in the inline presentation and are shown in full in menus.6566## Limits6768- `options` must contain the current selection, as with any `Picker`; otherwise nothing appears selected.69- Options must be unique (`Hashable` identity is used).70- The wheel exists only on iOS and iPadOS, radio buttons only on macOS.71- Single selection only.72