svelte-attach

Vibration

API docs
import { haptic, triggerHaptic, cancelHaptic } from "@joknoll/svelte-attach/haptic";

Presets

<button {@attach haptic("medium")}>medium</button>

Custom pattern

Enter milliseconds: vibrate, pause, vibrate…

<button {@attach haptic([25, 60, 40])}>Try</button>

Vibrate on press

<button {@attach haptic("heavy", { on: "pointerdown" })}>Press</button>

Trigger from code

<button onclick={() => triggerHaptic(2000)}>Start</button>
<button onclick={() => cancelHaptic()}>Stop</button>