Vibrate the Device
Trigger haptic feedback on user interactions using JavaScript or CSS classes
Vibration
Give users tactile feedback by triggering device vibration on interactions — for example, when scanning a QR code, completing an action, or tapping a button.
Vibrate with JavaScript
Call vibrate() with an intensity level from 0 (low) to 3 (intense):
await startiapp.App.vibrate(0); // Low
await startiapp.App.vibrate(1); // Medium
await startiapp.App.vibrate(2); // High
await startiapp.App.vibrate(3); // IntenseUse this when you want to control exactly when vibration happens — for example, when tapping a menu item, after validating a scanned QR code, or confirming a payment.
Vibrate with CSS classes
If you just want a button or other element to vibrate when tapped, you can skip JavaScript entirely. Add one of the vibration CSS classes to the element, and the SDK handles the rest:
| Intensity | CSS classes |
|---|---|
| Low | startiapp-v0, startiapp-v-l, startiapp-v-low |
| Medium | startiapp-v1, startiapp-v-m, startiapp-v-medium |
| High | startiapp-v2, startiapp-v-h, startiapp-v-high |
| Intense | startiapp-v3, startiapp-v-i, startiapp-v-intense |
<button class="startiapp-v-medium">Add to cart</button>The vibration is triggered on click — no event listeners needed.
The CSS classes work best with static HTML. If you add elements to the DOM dynamically (for example, rendering a list with JavaScript), the vibration classes may not be picked up. In that case, use the JavaScript vibrate() method instead.