Skip to content

Repository files navigation

📳 ios-haptics

javascript library for haptic feedback inside of safari on ios

GitHub last commit npm version NPM Downloads npm package minimized gzipped size

demo: ios-haptics demo

📦 installation

npm i ios-haptics

🚀 usage

import { hapticTrigger } from 'ios-haptics'

vanilla

const element = document.getElementById('element')

hapticTrigger(element)

svelte

<button {@attach hapticTrigger}>click me</button>

react

<button ref={hapticTrigger}>click me</button>

vue

<button :ref="hapticTrigger">click me</button>

⚙️ how it works

this uses the <input type="checkbox" switch /> (introduced in safari 17.4), which has haptic feedback when toggled

hapticTrigger renders one of those on top of your element, so when the user taps it, safari triggers the native haptic feedback


feel free to send a pr or open an issue if you have suggestions or find improvements

About

📳 javascript library for haptic feedback inside of safari on ios

Topics

Resources

Stars

118 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages