Contents

ersanq/haptickit

Haptic feedback in one line. No generators. No setup. No noise.

The Problem

// 😭 Native API β€” 4 lines for a single tap
let generator = UIImpactFeedbackGenerator(style: .medium)
generator.prepare()
generator.impactOccurred()

The Solution

// 😍 HapticKit β€” 1 line
Haptic.impact()

Features

  • βœ… 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+

Installation

https://github.com/ErsanQ/HapticKit

Or in Package.swift:

.package(url: "https://github.com/ErsanQ/HapticKit", from: "1.0.0")

Usage

Impact

Haptic.impact()           // medium (default)
Haptic.impact(.light)
Haptic.impact(.heavy)
Haptic.impact(.rigid)
Haptic.impact(.soft)

Notification

Haptic.success()   // task completed βœ…
Haptic.warning()   // caution ⚠️
Haptic.error()     // something went wrong ❌

Selection

Haptic.selection() // great for pickers, sliders, tab bars

Custom Intensity

Haptic.custom(intensity: 0.3)  // subtle
Haptic.custom(intensity: 1.0)  // maximum

Sequences

// 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)

SwiftUI Modifiers

// 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)

API Reference

Haptic

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

HapticEvent (for sequences)

.impact(.light/medium/heavy/rigid/soft) Β· .success Β· .warning Β· .error Β· .selection Β· .custom(intensity:)


Requirements

  • iOS 16.0+ / watchOS 9.0+ / visionOS 1.0+
  • Swift 5.9+
  • Xcode 15.0+

License

HapticKit is available under the MIT license. See the LICENSE file for more info.


Author

Built by Ersan Q Abo Esha β€” @ErsanQ

If HapticKit saved you time, consider giving it a ⭐️ on GitHub.

Package Metadata

Repository: ersanq/haptickit

Default branch: main

README: README.md