SP GlassKit1.1.0

GlassStepper

System stepper with bounds, increments and a formatted value.

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

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

GlassStepper 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-stepper

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-stepper
ModuleSPGlassForms
Kindnative-wrapper — the system Stepper with a formatted value in its label
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/Selection/GlassStepperExample.swift

Minimal usage

Swift
@State private var guests = 2

GlassStepper("Guests", value: $guests, in: 1...12)

Variants

VariantUse
Binding<Int>Whole numbers.
Binding<Double> with step:Fractional steps, without accumulated rounding noise.
format:Any text for the value: units, currency, percent.

Parameters

ParameterTypeDefaultMeaning
titleLocalizedStringKey—Title; also the accessibility label.
valueBinding<Int> or Binding<Double>—The value.
inClosedRange—Bounds.
stepInt or Double1Increment.
format(Value) -> Stringlocale-aware numberText 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...10 by 2 gives 1.5, 3.5, 5.5…;
  • ten steps of 0.1 from 0 give exactly 1.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...10 by 3), 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 GlassTextField if 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.

Example

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

public struct GlassStepperExample: GlassExample {
    public static let componentID = "glass-stepper"
    @State private var guests = 2
    @State private var dose = 0.5
    @State private var zoom = 1.0
    @State private var fixed = 3

    public init() {}

    public var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: 20) {
                GlassStepper("Guests", value: $guests, in: 1...12)

                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, numberFormatStyle: .number.precision(.fractionLength(2))))
                }

                // The upper bound 4 is not on a step from 0.5 by 0.75: the last press stops at the bound.
                GlassStepper("Zoom", value: $zoom, in: 0.5...4, step: 0.75) { value in
                    value.formatted(.percent.precision(.fractionLength(0)))
                }

                GlassStepper("Seats (fixed by your plan)", value: $fixed, in: 1...5)
                    .disabled(true)
            }
            .padding()
        }
    }
}

#Preview("GlassStepper") { GlassStepperExample().glassTheme(.crystal) }

Registry entry

Identifierglass-stepper
Version1.1.0
Depends onglass-foundation
FrameworksSwiftUI
Public symbolsGlassStepperMath, Direction, GlassStepper
LicenceMIT
Manifestmanifest.json

Files