Vue NativeVue Native
Guide
Components
Composables
Navigation
  • iOS
  • Android
  • macOS
GitHub
Guide
Components
Composables
Navigation
  • iOS
  • Android
  • macOS
GitHub
  • Device & System

    • useNetwork
    • useAppState
    • useColorScheme
    • useDeviceInfo
    • useDimensions
    • usePlatform
  • Storage & Files

    • useAsyncStorage
    • useSecureStorage
    • useFileSystem
    • useDatabase
  • Sensors & Hardware

    • useGeolocation
    • useBiometry
    • useHaptics
    • useSensors
    • useBluetooth
  • Media

    • useCamera
    • useAudio
    • useCalendar
    • useContacts
  • Networking

    • useHttp
    • useWebSocket
  • Permissions

    • usePermissions
  • Navigation

    • useBackHandler
    • useSharedElementTransition
  • UI

    • useKeyboard
    • useClipboard
    • useShare
    • useLinking
    • useAnimation
    • useGesture
    • useNotifications
    • useI18n
    • usePerformance
  • Authentication

    • useAppleSignIn
    • useGoogleSignIn
  • Monetization & Updates

    • useIAP
    • useOTAUpdate
    • useBackgroundTask
  • Desktop (macOS)

    • useWindow
    • useMenu
    • useFileDialog
    • useDragDrop

useHaptics

Haptic feedback for touch interactions. Provides three types of tactile feedback: impact (for button taps and collisions), notification (for success/warning/error outcomes), and selection (for picker changes).

Usage

<script setup>
import { useHaptics } from '@thelacanians/vue-native-runtime'

const { vibrate, notificationFeedback, selectionChanged } = useHaptics()
</script>

<template>
  <VButton :onPress="() => vibrate('medium')">
    <VText>Tap me</VText>
  </VButton>
</template>

API

useHaptics(): {
  vibrate: (style?: ImpactStyle) => Promise<void>
  notificationFeedback: (type?: NotificationType) => Promise<void>
  selectionChanged: () => Promise<void>
}

Return Value

MethodSignatureDescription
vibrate(style?: ImpactStyle) => Promise<void>Trigger impact feedback. Defaults to 'medium'.
notificationFeedback(type?: NotificationType) => Promise<void>Trigger notification feedback. Defaults to 'success'.
selectionChanged() => Promise<void>Trigger selection feedback, typically used when a user scrolls through a picker.

Types

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

type NotificationType = 'success' | 'warning' | 'error'

Impact Styles

StyleUse Case
'light'Small, subtle interactions (toggle switch)
'medium'Standard button taps
'heavy'Significant actions (drag drop, force press)
'rigid'Sharp, precise feedback
'soft'Gentle, muted feedback

Platform Support

PlatformSupport
iOSUses UIImpactFeedbackGenerator, UINotificationFeedbackGenerator, and UISelectionFeedbackGenerator.
AndroidUses HapticFeedbackConstants and Vibrator service.

Example

<script setup>
import { useHaptics } from '@thelacanians/vue-native-runtime'

const { vibrate, notificationFeedback, selectionChanged } = useHaptics()

function onAddToCart() {
  vibrate('medium')
}

function onPaymentSuccess() {
  notificationFeedback('success')
}

function onPaymentError() {
  notificationFeedback('error')
}
</script>

<template>
  <VView :style="{ padding: 20, gap: 12 }">
    <VText :style="{ fontSize: 18, fontWeight: 'bold' }">Haptics Demo</VText>

    <VButton :onPress="() => vibrate('light')"><VText>Impact: Light</VText></VButton>
    <VButton :onPress="() => vibrate('medium')"><VText>Impact: Medium</VText></VButton>
    <VButton :onPress="() => vibrate('heavy')"><VText>Impact: Heavy</VText></VButton>
    <VButton :onPress="() => notificationFeedback('success')"><VText>Notify: Success</VText></VButton>
    <VButton :onPress="() => notificationFeedback('warning')"><VText>Notify: Warning</VText></VButton>
    <VButton :onPress="() => notificationFeedback('error')"><VText>Notify: Error</VText></VButton>
    <VButton :onPress="selectionChanged"><VText>Selection</VText></VButton>
  </VView>
</template>

Notes

  • This composable has no reactive state and no cleanup. All methods return Promises that resolve once the native haptic engine fires.
  • Haptic feedback is a no-op on devices without a haptic engine (e.g., simulator, older iPads).
  • Use haptics sparingly — overuse diminishes their impact and can annoy users. Apple's Human Interface Guidelines recommend haptics only for meaningful interactions.
Edit this page
Last Updated: 2/28/26, 11:24 PM
Contributors: Abdul Hamid, Claude Opus 4.6
Prev
useBiometry
Next
useSensors