Library / Taps & buttons

Toggle / switch flip

A settings switch flips on or off with a mechanical click.

0ms 100ms 200ms 300ms 400ms
Feel
A crisp, rigid tick — like a physical switch. Slightly stronger on "on".
APIs
.sensoryFeedback(.impact(flexibility: .rigid))UIImpactFeedbackGenerator(style: .rigid)
Minimum OS
iOS 17+ / iOS 13+
Raw .md
SwiftUI (iOS 17+)
import SwiftUI

struct HapticToggle: View {
    @State private var isOn = false

    var body: some View {
        Toggle("Notifications", isOn: $isOn)
            .sensoryFeedback(trigger: isOn) { _, on in
                .impact(flexibility: .rigid, intensity: on ? 0.7 : 0.5)
            }
    }
}
UIKit
let toggle = UISwitch()
let haptic = UIImpactFeedbackGenerator(style: .rigid)

toggle.addAction(UIAction { action in
    guard let sender = action.sender as? UISwitch else { return }
    haptic.impactOccurred(intensity: sender.isOn ? 0.7 : 0.5)
}, for: .valueChanged)
Copied