Demo
Status
Checking availability...
Impact Feedback
Physical feedback for UI element interactions like button taps.
Notification Feedback
Feedback patterns for success, warning, and error states.
Selection Feedback
For picker wheels, sliders, and selection changes.
Custom Vibration
Direct vibration with custom duration (in milliseconds).
Note: Haptic feedback is available on iOS devices with Taptic Engine and Android devices with vibration motors. On devices without haptic engines, some feedback falls back to simple vibration.
Usage
import { useHaptics } from '@classic-homes/native/svelte';
// or for React:
import { useHaptics } from '@classic-homes/native/react';API Reference
| Property | Type | Description |
|---|---|---|
| isAvailable | boolean | null | Whether haptics are available |
| error | Error | null | Current error if any |
| impact | (style?: 'light' | 'medium' | 'heavy') => Promise<void> | Trigger impact feedback |
| notification | (type?: 'success' | 'warning' | 'error') => Promise<void> | Trigger notification feedback |
| selectionStart | () => Promise<void> | Start selection feedback |
| selectionChanged | () => Promise<void> | Continue selection feedback |
| selectionEnd | () => Promise<void> | End selection feedback |
| vibrate | (duration?: number) => Promise<void> | Trigger vibration for specified duration |