zairigimad/ux-haptics

Symfony UX bundle for haptic feedback on the mobile web using web-haptics

Maintainers

Package info

github.com/zairigimad/ux-haptics

Type:symfony-bundle

pkg:composer/zairigimad/ux-haptics

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.0 2026-03-10 22:25 UTC

This package is auto-updated.

Last update: 2026-04-11 12:35:29 UTC


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