Repository Public MIT
1# GlassStepper23| | |4|---|---|5| Identifier | `glass-stepper` |6| Module | `SPGlassForms` |7| Kind | `native-wrapper` — the system `Stepper` with a formatted value in its label |8| Platforms | iOS 26, iPadOS 26, macOS 26 |9| Example | `Examples/Gallery/Selection/GlassStepperExample.swift` |1011## Minimal usage1213```swift14@State private var guests = 21516GlassStepper("Guests", value: $guests, in: 1...12)17```1819## Variants2021| Variant | Use |22|---|---|23| `Binding<Int>` | Whole numbers. |24| `Binding<Double>` with `step:` | Fractional steps, without accumulated rounding noise. |25| `format:` | Any text for the value: units, currency, percent. |2627## Parameters2829| Parameter | Type | Default | Meaning |30|---|---|---|---|31| `title` | `LocalizedStringKey` | — | Title; also the accessibility label. |32| `value` | `Binding<Int>` or `Binding<Double>` | — | The value. |33| `in` | `ClosedRange` | — | Bounds. |34| `step` | `Int` or `Double` | `1` | Increment. |35| `format` | `(Value) -> String` | locale-aware number | Text of the value. |3637## States3839Idle, pressed and focused are drawn by the system. At a bound the matching button is disabled. The whole control is disabled with `.disabled(_:)`.4041## Advanced example4243```swift44GlassStepper("Dose", value: $dose, in: 0...2.5, step: 0.25) { value in45 Measurement(value: value, unit: UnitMass.milligrams)46 .formatted(.measurement(width: .abbreviated, usage: .asProvided))47}48```4950The arithmetic is the pure function `GlassStepperMath.stepped(_:by:_:in:)`:5152- steps are counted from the lower bound, so `1.5...10` by `2` gives 1.5, 3.5, 5.5…;53- ten steps of `0.1` from `0` give exactly `1.0`;54- a value between two steps moves to the neighbouring step, not a full step away;55- when the upper bound is not on a step (`0...10` by `3`), incrementing from 9 stops at 10 and decrementing from 10 returns to 9.5657## Accessibility5859- The stepper is one adjustable element: label = title, value = the formatted text, swipe up and down to change it.60- The value is visible next to the title, in monospaced digits, and moves under the title when the two do not fit on one line.61- A bound is conveyed by the disabled button, not by colour.6263## Limits6465- No press-and-hold acceleration beyond what the system gives to the buttons.66- No direct text entry; pair the stepper with a `GlassTextField` if typing a value is needed.67- Values with more than nine decimals are outside what the rounding clean-up handles.68- GlassKit replaces the stepper's accessibility children by one adjustable element; that VoiceOver and Switch Control behave as described was not checked on a running device.69