vael-ui v0.5.7

Utilities

useHaptic

Plays haptic feedback on phones that support it: a light tick, a bump, a short success, warning or error pattern, or your own. Use it for moments that commit something.

Plays haptic feedback on phones that support it: navigator.vibrate on Android, and on iOS (Safari 17.4+) the tick a native switch plays. Desktops do nothing, and isSupported tells you which you have. intensity scales every pulse. ConfigProvider's haptics sets it app-wide: false silences every call, yours included, for a "turn off haptics" setting, and true or { intensity } also turns on vael-ui's own haptics. Call it from a user gesture, and keep it for moments that commit something.

Install

import { useHaptic } from 'vael-ui'

Examples

Parameters

NameTypeDescription
intensitynumberScales every pulse: 0.5 is softer, 2 stronger. Default 1. Multiplies with ConfigProvider's haptics.intensity. On Android it lengthens each pulse; iOS plays one fixed-strength tick per pulse.

Returns

NameTypeDescription
isSupportedbooleanWhether this device plays haptics.
selection() => voidPlays the lightest tick, for a choice changing.
impact(weight?: 'light' | 'medium' | 'heavy') => voidPlays a bump, heavier for bigger moments. Default 'medium'.
notification(type: 'success' | 'warning' | 'error') => voidPlays a short pattern for an outcome.
vibrate(pattern: number | number[]) => voidPlays your own pattern in ms, vibration and pause alternating. iOS plays a tick per pulse.