Course contentsShow
← React Native
Lesson 218 of 1,5553. Core Primitive ComponentsFree lesson

Implementing Haptic Feedback Triggers

Learners will signal success or error states using subtle vibration patterns.

In this lesson, you will learn how to improve the "feel" of your application by triggering physical vibration patterns that signal success or error states to the user.

Why use Haptics?

When a user interacts with your app—like submitting a form or encountering an error—visual feedback is important, but tactile feedback makes the experience feel polished and native. Haptics provide a subtle physical "thud" or "tap" that confirms an action has been registered, even if the user isn't looking directly at the screen.

In React Native, we handle these triggers through the Vibration module. It allows us to access the hardware's vibration motor to create distinct patterns.

Implementing Success and Error States

To signal a success state, we usually trigger a short, sharp vibration. For an error state, we can use a slightly longer or repeated pattern to signal that something went wrong.

Here is how you can trigger these patterns:

import { Vibration } from 'react-native';

const handleSuccess = () => {
  // A quick vibration pattern [delay, vibration_duration]
  Vibration.vibrate(100); 
};

const handleError = () => {
  // Pattern: vibrate for 200ms, pause for 100ms, vibrate for 200ms
  Vibration.vibrate([200, 100, 200]);
};

Best Practices for Tactile Design

  • Keep it subtle: Haptics should be a secondary confirmation, not the primary focus. Use short durations (under 200ms) for success signals to avoid being jarring.
  • Use for state changes: Reserve haptics for significant actions, such as a successful save, a failed login attempt, or reaching the end of a Scroll View list.
  • User Preference: Always keep in mind that users can disable vibrations in their system settings. Your UI should always provide visual feedback (like an alert or color change) alongside the haptic, so the app remains accessible even when haptics aren't available.

By pairing haptic triggers with your existing UI states, you transform your app from a flat interface into a responsive tool that responds to the user's touch.

Key Takeaway: Haptic feedback bridges the gap between digital interaction and physical response, creating a more professional and intuitive user experience.