GlassStepper
| Identifier | glass-stepper |
| Module | SPGlassForms |
| Kind | native-wrapper — the system Stepper with a formatted value in its label |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Selection/GlassStepperExample.swift |
Minimal usage
swift
@State private var guests = 2
GlassStepper("Guests", value: $guests, in: 1...12)Variants
| Variant | Use |
|---|---|
Binding<Int> |
Whole numbers. |
Binding<Double> with step: |
Fractional steps, without accumulated rounding noise. |
format: |
Any text for the value: units, currency, percent. |
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
title |
LocalizedStringKey |
— | Title; also the accessibility label. |
value |
Binding<Int> or Binding<Double> |
— | The value. |
in |
ClosedRange |
— | Bounds. |
step |
Int or Double |
1 |
Increment. |
format |
(Value) -> String |
locale-aware number | Text of the value. |
States
Idle, pressed and focused are drawn by the system. At a bound the matching button is disabled. The whole control is disabled with .disabled(_:).
Advanced example
swift
GlassStepper("Dose", value: $dose, in: 0...2.5, step: 0.25) { value in
Measurement(value: value, unit: UnitMass.milligrams)
.formatted(.measurement(width: .abbreviated, usage: .asProvided))
}The arithmetic is the pure function GlassStepperMath.stepped(_:by:_:in:):
- steps are counted from the lower bound, so
1.5...10by2gives 1.5, 3.5, 5.5…; - ten steps of
0.1from0give exactly1.0; - a value between two steps moves to the neighbouring step, not a full step away;
- when the upper bound is not on a step (
0...10by3), incrementing from 9 stops at 10 and decrementing from 10 returns to 9.
Accessibility
- The stepper is one adjustable element: label = title, value = the formatted text, swipe up and down to change it.
- 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.
- A bound is conveyed by the disabled button, not by colour.
Limits
- No press-and-hold acceleration beyond what the system gives to the buttons.
- No direct text entry; pair the stepper with a
GlassTextFieldif typing a value is needed. - Values with more than nine decimals are outside what the rounding clean-up handles.
- 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.