zairigimad / ux-haptics
Symfony UX bundle for haptic feedback on the mobile web using web-haptics
Package info
github.com/zairigimad/ux-haptics
Type:symfony-bundle
pkg:composer/zairigimad/ux-haptics
v1.0.0
2026-03-10 22:25 UTC
Requires
- php: >=8.2
- symfony/console: ^7.0 || ^8.0
- symfony/dependency-injection: ^7.0 || ^8.0
- symfony/http-kernel: ^7.0 || ^8.0
Requires (Dev)
- php-cs-fixer/shim: ^3.94
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^9.6
- symfony/asset-mapper: ^7.0 || ^8.0
- symfony/framework-bundle: ^7.0 || ^8.0
- symfony/phpunit-bridge: ^7.0 || ^8.0
- symfony/stimulus-bundle: ^2.9
- symfony/twig-bundle: ^7.0 || ^8.0
- twig/twig: ^3.0
README
Haptic feedback for the mobile web in Symfony, powered by web-haptics and Stimulus.
Installation
composer require zairigimad/ux-haptics
If you're using AssetMapper, also run:
php bin/console importmap:require web-haptics
Usage
With stimulus_controller() (recommended)
{# Preset #} <button {{ stimulus_controller('zairigimad/ux-haptics/haptics', { preset: 'success' }) }}> Tap me </button> {# Custom pattern #} <button {{ stimulus_controller('zairigimad/ux-haptics/haptics', { pattern: [ { duration: 30 }, { delay: 60, duration: 40, intensity: 1 }, ], }) }}> Custom haptic </button>
With bundled Twig helpers
<button {{ haptics_preset('success') }}>Tap me</button> <button {{ haptics_preset('error', { intensity: 1.0 }) }}>Delete</button> <button {{ haptics_pattern([{ 'duration': 100 }]) }}>Ping</button>
Plain HTML
<button data-controller="zairigimad--ux-haptics--haptics" data-zairigimad--ux-haptics--haptics-preset-value="success" > Tap me </button>
Available Options
| Option | Type | Default | Description |
|---|---|---|---|
preset |
String | '' |
Predefined preset name |
pattern |
Array | [] |
Custom {duration, delay?, intensity?} steps |
intensity |
Number | 0.5 |
Global intensity (0.0–1.0) |
event |
String | 'click' |
DOM event that triggers the haptic |
auto |
Boolean | false |
Fire on page load instead of event |
debug |
Boolean | false |
Audio feedback for desktop testing |
show_switch |
Boolean | false |
Show web-haptics toggle UI |
Built-in Presets
success · nudge · error · buzz · warning · light · medium · heavy · soft · rigid · selection
Requirements
- PHP 8.2+
- Symfony 7.x or 8.x
symfony/stimulus-bundle^2.9
License
MIT