Pulled ALL skills from 15 source repositories: - anthropics/skills: 16 (docs, design, MCP, testing) - obra/superpowers: 14 (TDD, debugging, agents, planning) - coreyhaines31/marketingskills: 25 (marketing, CRO, SEO, growth) - better-auth/skills: 5 (auth patterns) - vercel-labs/agent-skills: 5 (React, design, Vercel) - antfu/skills: 16 (Vue, Vite, Vitest, pnpm, Turborepo) - Plus 13 individual skills from various repos Mosaic Stack is not limited to coding — the Orchestrator and subagents serve coding, business, design, marketing, writing, logistics, analysis, and more. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
84 lines
2.2 KiB
Markdown
84 lines
2.2 KiB
Markdown
---
|
|
category: Browser
|
|
---
|
|
|
|
# useVibrate
|
|
|
|
Reactive [Vibration API](https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API)
|
|
|
|
Most modern mobile devices include vibration hardware, which lets software
|
|
code provides physical feedback to the user by causing the device to shake.
|
|
|
|
The Vibration API offers Web apps the ability to access this hardware,
|
|
if it exists, and does nothing if the device doesn't support it.
|
|
|
|
## Usage
|
|
|
|
Vibration is described as a pattern of on-off pulses, which may be of varying
|
|
lengths.
|
|
|
|
The pattern may consist of either a single integer describing the
|
|
number of milliseconds to vibrate, or an array of integers describing
|
|
a pattern of vibrations and pauses.
|
|
|
|
```ts
|
|
import { useVibrate } from '@vueuse/core'
|
|
|
|
// This vibrates the device for 300 ms
|
|
// then pauses for 100 ms before vibrating the device again for another 300 ms:
|
|
const { vibrate, stop, isSupported } = useVibrate({ pattern: [300, 100, 300] })
|
|
|
|
// Start the vibration, it will automatically stop when the pattern is complete:
|
|
vibrate()
|
|
|
|
// But if you want to stop it, you can:
|
|
stop()
|
|
```
|
|
|
|
## Type Declarations
|
|
|
|
```ts
|
|
export interface UseVibrateOptions extends ConfigurableNavigator {
|
|
/**
|
|
*
|
|
* Vibration Pattern
|
|
*
|
|
* An array of values describes alternating periods in which the
|
|
* device is vibrating and not vibrating. Each value in the array
|
|
* is converted to an integer, then interpreted alternately as
|
|
* the number of milliseconds the device should vibrate and the
|
|
* number of milliseconds it should not be vibrating
|
|
*
|
|
* @default []
|
|
*
|
|
*/
|
|
pattern?: MaybeRefOrGetter<number[] | number>
|
|
/**
|
|
* Interval to run a persistent vibration, in ms
|
|
*
|
|
* Pass `0` to disable
|
|
*
|
|
* @default 0
|
|
*
|
|
*/
|
|
interval?: number
|
|
}
|
|
/**
|
|
* Reactive vibrate
|
|
*
|
|
* @see https://vueuse.org/useVibrate
|
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API
|
|
* @param options
|
|
*
|
|
* @__NO_SIDE_EFFECTS__
|
|
*/
|
|
export declare function useVibrate(options?: UseVibrateOptions): {
|
|
isSupported: ComputedRef<boolean>
|
|
pattern: MaybeRefOrGetter<number | number[]>
|
|
intervalControls: Pausable | undefined
|
|
vibrate: (pattern?: number | number[]) => void
|
|
stop: () => void
|
|
}
|
|
export type UseVibrateReturn = ReturnType<typeof useVibrate>
|
|
```
|