Explore all built-in haptic patterns available in WebHaptics
WebHaptics provides 11 carefully crafted haptic patterns inspired by iOS feedback generators. Each pattern is designed to communicate specific interactions and states through vibration.
// Trigger with 80% intensityhaptics.trigger('medium', { intensity: 0.8 });// Trigger with 30% intensity for subtle feedbackhaptics.trigger('heavy', { intensity: 0.3 });
The intensity option acts as a multiplier for vibrations that don’t have an explicit intensity value. Individual vibrations with defined intensities in the pattern remain unchanged.
Pattern Comparison
Compare different patterns to find the right feel:
// Short and crisphaptics.trigger('rigid'); // 10ms at intensity 1haptics.trigger('selection'); // 8ms at intensity 0.3// Medium durationhaptics.trigger('light'); // 15ms at intensity 0.4haptics.trigger('medium'); // 25ms at intensity 0.7haptics.trigger('heavy'); // 35ms at intensity 1// Longer feedbackhaptics.trigger('soft'); // 40ms at intensity 0.5
All patterns are defined using the Vibration interface:
interface Vibration { duration: number; // Duration in milliseconds intensity?: number; // Intensity from 0 to 1 delay?: number; // Delay before this vibration in milliseconds}
Durations are clamped to a maximum of 1000ms due to browser haptic API limitations.