Command palette

@yasinsensoy/native

React Native · APIs and utilities

Haptics

Haptic feedback.

3 exports

Import

import { Haptics } from "@yasinsensoy/native";

Haptics

module

Haptic feedback. Calls can be used without awaiting (errors are swallowed).

NameTypeDescription
isSupported() => booleanWhether the device has a vibration motor.
impact(style?: ImpactStyle) => Promise<void>Tap/impact feel (buttons, drag and drop).
notification(type?: NotificationFeedback) => Promise<void>Result feel: success (two short), warning, error (three short).
selection() => Promise<void>Selection changed feel (slider step, picker). The lightest feedback.
vibrate(pattern?: number | readonly number[]) => Promise<void>Free-form vibration. A number: duration (ms). An array: [wait, vibrate, wait, vibrate…] (ms). iOS does not allow setting the duration: the system vibration (~400 ms) plays once for each vibration in the pattern.
cancel() => Promise<void>Stops an ongoing vibration.

Impact strength: light, medium, heavy; soft soft, rigid hard/short.

type ImpactStyle = "light" | "medium" | "heavy" | "soft" | "rigid"

Result notification: success, warning or error.

type NotificationFeedback = "success" | "warning" | "error"