expo-haptics
Version: 55.0.6 Provides access to the system’s haptics engine on iOS, vibration effects on Android, and Web Vibration API on web.Installation
Usage
API Reference
Impact Feedback
(style: ImpactFeedbackStyle) => Promise<void>
Triggers impact haptic feedbackStyles:
Haptics.ImpactFeedbackStyle.LightHaptics.ImpactFeedbackStyle.MediumHaptics.ImpactFeedbackStyle.HeavyHaptics.ImpactFeedbackStyle.Rigid(iOS 13+)Haptics.ImpactFeedbackStyle.Soft(iOS 13+)
Notification Feedback
(type: NotificationFeedbackType) => Promise<void>
Triggers notification haptic feedbackTypes:
Haptics.NotificationFeedbackType.SuccessHaptics.NotificationFeedbackType.WarningHaptics.NotificationFeedbackType.Error
Selection Feedback
() => Promise<void>
Triggers selection change haptic feedback
Examples
Button Press Feedback
Form Validation Feedback
Picker Selection
Different Impact Levels
Platform Support
iOS: Uses
UIImpactFeedbackGenerator, UINotificationFeedbackGenerator, and UISelectionFeedbackGeneratorAndroid: Uses VibrationEffect (API 26+) or Vibrator for older versionsWeb: Uses the Vibration API where supportedBest Practices
- Use Sparingly: Overuse can be annoying
- Match Interaction: Use appropriate feedback type for the interaction
- Respect Settings: Haptics honor system settings (vibration off, etc.)
- Light for UI: Use
Lightimpact for most UI interactions - Notifications for States: Use notification feedback for success/error states