Haptic feedback for React on iOS, Android, and the web.
npm install joeblau/hapticimport { Haptic } from "@joeblau/haptic"
export function Button() {
return (
<Haptic>
<button onClick={() => console.log("Tapped")}>Tap me</button>
</Haptic>
)
}The original element keeps its handlers, ref, focus behavior, and accessibility attributes.
<Haptic
enabled={true}
feedback="selection"
style={{ display: "grid", width: "100%" }}
>
<button>Continue</button>
</Haptic>enabledturns haptics on or off.disableddisables haptics for the target.feedbackselects aweb-hapticspreset or pattern.styleandclassNamecustomize the wrapper.
Disabled buttons are detected automatically.
iOS haptics require a physical tap. Programmatic events, timers, and asynchronous callbacks cannot trigger them.