Library / Pickers, sliders & steppers

Stepper increase / decrease

Quantity steppers (+ / −): direction-aware feedback so up and down feel different.

0ms 100ms 200ms 300ms 400ms
Feel
.increase is a slightly rising tick, .decrease slightly falling; the ends give a firmer "limit" bump.
APIs
.sensoryFeedback(.increase / .decrease)
Minimum OS
iOS 17+
Raw .md
SwiftUI (iOS 17+)
import SwiftUI

struct QuantityStepper: View {
    @State private var quantity = 1
    @State private var limitBump = 0
    let range = 1...9

    var body: some View {
        HStack(spacing: 20) {
            Button { decrement() } label: { Image(systemName: "minus.circle.fill") }
            Text("\(quantity)").font(.title2.monospacedDigit())
            Button { increment() } label: { Image(systemName: "plus.circle.fill") }
        }
        .font(.title)
        // Direction-aware ticks:
        .sensoryFeedback(trigger: quantity) { old, new in
            new > old ? .increase : .decrease
        }
        // Firm bump when pushing against a limit:
        .sensoryFeedback(.impact(flexibility: .rigid, intensity: 0.9),
                         trigger: limitBump)
    }

    func increment() {
        if quantity < range.upperBound { quantity += 1 } else { limitBump += 1 }
    }
    func decrement() {
        if quantity > range.lowerBound { quantity -= 1 } else { limitBump += 1 }
    }
}
Copied