UNPKG

use-haptic

Version:

A convenient React hook to trigger haptic feedback anywhere in your application

24 lines 850 B
/** * React hook for triggering haptic feedback on mobile devices * * This hook creates hidden DOM elements to trigger haptic feedback using the `input[switch]` * element for iOS devices and falls back to the Vibration API for other supported devices. * * @param {number} duration - The duration of the vibration in milliseconds (default: 100ms) * @returns {Object} An object containing the `triggerHaptic` function to trigger haptic feedback * * @example * ```tsx * import { useHaptic } from "use-haptic"; * * function HapticButton() { * const { triggerHaptic } = useHaptic(200); // 200ms vibration * return <button onClick={triggerHaptic}>Vibrate</button>; * } * ``` */ export declare const useHaptic: (duration?: number) => { triggerHaptic: () => void; }; export default useHaptic; //# sourceMappingURL=useHaptic.d.ts.map