Cross platform React Native Haptics using native Android and iOS haptic functionality
Minimum requirements
- iOS 10+
- Android API 16+
- React Native 0.60+
This library creates a bridge of the following native modules
NPM
npm install react-native-haptics
Yarn
yarn add react-native-haptics
No additional steps needed
Selection
import Haptics, {HapticsType} from 'react-native-haptics';
Haptics.trigger(HapticsType.selection);
Impact Light
import Haptics, {HapticsType} from 'react-native-haptics';
Haptics.trigger(HapticsType.impactLight);
Impact medium
import Haptics, {HapticsType} from 'react-native-haptics';
Haptics.trigger(HapticsType.impactLight);
Impact Heavy
import Haptics, {HapticsType} from 'react-native-haptics';
Haptics.trigger(HapticsType.impactHeavy);
Notification Success
import Haptics, {HapticsType} from 'react-native-haptics';
Haptics.trigger(HapticsType.notificationSuccess);
Notification Warning
import Haptics, {HapticsType} from 'react-native-haptics';
Haptics.trigger(HapticsType.notificationWarning);
Notification Error
import Haptics, {HapticsType} from 'react-native-haptics';
Haptics.trigger(HapticsType.notificationError);
Through the constant HapticsType
we provide different types of haptics. You can read more about the different types and how they should be used.
Haptics Type | Usage |
---|---|
selection | Selection. Indicates that the selection is actively changing. For example, the user feels light taps while scrolling a picker wheel. This feedback is intended for communicating movement through a series of discrete values, not making or confirming a selection. |
impactLight | Light. Provides a physical metaphor that complements the visual experience. For example, people might feel a thud when a view slides into place or two objects collide. |
impactMedium | Medium. Provides a physical metaphor that complements the visual experience. For example, people might feel a thud when a view slides into place or two objects collide. |
impactHeavy | Heavy. Provides a physical metaphor that complements the visual experience. For example, people might feel a thud when a view slides into place or two objects collide. |
notificationSuccess | Success. Indicates that a task or action, such as depositing a check or unlocking a vehicle, has completed. |
notificationWarning | Warning. Indicates that a task or action, such as depositing a check or unlocking a vehicle, has produced a warning of some kind. |
notificationError | Failure. Indicates that a task or action, such as depositing a check or unlocking a vehicle, has failed. |
MIT