Haptics

Trigger device vibrations when users tap buttons, submit forms, or complete actions. Haptics add tactile feedback that makes your app feel more responsive and native.

Works in both Normal Mode and Advanced Mode with the same helper.

#Basic usage

Add native_haptic_data to any clickable element. When the user taps it, the device vibrates.

<%= button_tag "Delete", data: native_haptic_data(:error) %>

The helper returns a data hash, so you can merge it with other attributes:

<%= link_to "Save", save_path, data: { turbo_method: :post, **native_haptic_data } %>

No signal element or controller markup needed. The helper handles both modes automatically.

#Feedback types

Pass a feedback type to control the vibration style. Defaults to :success.

Type Feel Use case
:success Positive confirmation Saved, completed, toggled on
:warning Cautionary Destructive action confirmed, limit reached
:error Rejection Validation failed, action blocked
:impact Light physical tap Button press, drag threshold
:selection Subtle tick Picker changed, option selected
<%= button_tag "Save", data: native_haptic_data(:success) %>
<%= button_tag "Delete", data: native_haptic_data(:error) %>
<%= button_tag "Tap me", data: native_haptic_data(:impact) %>

Unknown or blank values default to :success.

#JavaScript API

Trigger haptics programmatically from JavaScript:

RubyNative.haptic("success")
RubyNative.haptic("error")
RubyNative.haptic() // defaults to "success"

This works in both modes. Use it for non-click events like form validation failures, drag thresholds, or animation completions.