Skip to main content
Provides haptic feedback to enhance user interactions through physical sensations. The haptics API includes three methods for different types of feedback: impact, notification, and selection.

Usage

Methods

impactOccurred

Triggers impact feedback, useful for simulating physical impacts.

Parameters

type
  • Type: 'light' | 'medium' | 'heavy' | 'soft' | 'rigid'
The intensity and style of the impact feedback.
  • light: A light impact
  • medium: A medium impact
  • heavy: A heavy impact
  • soft: A soft, dampened impact
  • rigid: A sharp, rigid impact

Example

notificationOccurred

Triggers notification feedback, ideal for indicating task outcomes.

Parameters

type
  • Type: 'success' | 'warning' | 'error'
The type of notification feedback.
  • success: Indicates a successful operation
  • warning: Indicates a warning or caution
  • error: Indicates an error or failure

Example

selectionChanged

Triggers selection feedback, perfect for UI element selections.

Example

Return Value

All haptic methods return Promise<void>.

Availability

Haptic feedback availability depends on the client device and platform. You can check if haptics are supported using the getCapabilities() method:

Best Practices

  1. Use sparingly: Overuse of haptic feedback can be distracting
  2. Match intensity to action: Use light feedback for minor actions, heavy for significant ones
  3. Provide visual feedback too: Not all devices support haptics
  4. Check availability: Always verify haptic support before using
  5. Consider context: Some users may have haptics disabled in their device settings

Related topics

What's NewContext