Haptic feedback in one line. No generators. No setup. No noise.
// 😭 Native API — 4 lines for a single tap
let generator = UIImpactFeedbackGenerator(style: .medium)
generator.prepare()
generator.impactOccurred()// 😍 HapticKit — 1 line
Haptic.impact()- ✅
Haptic.impact()— light, medium, heavy, rigid, soft - ✅
Haptic.success()/.warning()/.error() - ✅
Haptic.selection()— for pickers and toggles - ✅
Haptic.custom(intensity: 0.75)— precise control - ✅
Haptic.sequence([...], delay:)— chain multiple haptics - ✅ SwiftUI modifiers —
.hapticFeedback(),.hapticSuccess(),.hapticError() - ✅ Automatically disabled on iPad and non-haptic devices
- ✅ Zero dependencies — wraps native
UIFeedbackGenerator - ✅ iOS 16+, watchOS 9+, visionOS 1+
https://github.com/ErsanQ/HapticKit
Or in Package.swift:
.package(url: "https://github.com/ErsanQ/HapticKit", from: "1.0.0")Haptic.impact() // medium (default)
Haptic.impact(.light)
Haptic.impact(.heavy)
Haptic.impact(.rigid)
Haptic.impact(.soft)Haptic.success() // task completed ✅
Haptic.warning() // caution ⚠️
Haptic.error() // something went wrong ❌Haptic.selection() // great for pickers, sliders, tab barsHaptic.custom(intensity: 0.3) // subtle
Haptic.custom(intensity: 1.0) // maximum// Double tap
Haptic.sequence([.impact(.light), .impact(.heavy)], delay: 0.1)
// Success celebration
Haptic.sequence([
.impact(.light),
.impact(.medium),
.impact(.heavy),
.success
], delay: 0.08)// Trigger on value change
Toggle("Notifications", isOn: $isOn)
.hapticFeedback(.impact(.medium), trigger: isOn)
// On success
Button("Save") { save() }
.hapticSuccess(trigger: isSaved)
// On error
TextField("Email", text: $email)
.hapticError(trigger: hasError)
// On selection
Picker("Theme", selection: $theme) { ... }
.hapticSelection(trigger: theme)| Method | Description |
|---|---|
impact(_ style:) |
Impact feedback (default: .medium) |
success() |
Success notification |
warning() |
Warning notification |
error() |
Error notification |
notify(_ style:) |
Notification with explicit style |
selection() |
Selection changed |
custom(intensity:) |
Impact at custom intensity (0.0–1.0) |
sequence(_ events:delay:) |
Chain multiple haptics |
.impact(.light/medium/heavy/rigid/soft) · .success · .warning · .error · .selection · .custom(intensity:)
- iOS 16.0+ / watchOS 9.0+ / visionOS 1.0+
- Swift 5.9+
- Xcode 15.0+
HapticKit is available under the MIT license. See the LICENSE file for more info.
Built by Ersan Q Abo Esha — @ErsanQ
If HapticKit saved you time, consider giving it a ⭐️ on GitHub.
