Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/usePointer.md
1---2category: Sensors3---45# usePointer67Reactive [pointer state](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events).89## Basic Usage1011```ts12import { usePointer } from '@vueuse/core'1314const { x, y, pressure, pointerType } = usePointer()15```1617## Component Usage1819By default, the component will track the pointer on `window`2021```vue22<template>23<UsePointer v-slot="{ x, y }">24x: {{ x }}25y: {{ y }}26</UsePointer>27</template>28```2930To track local position in the element, set `target="self"`:3132```vue33<template>34<UsePointer v-slot="{ x, y }" target="self">35x: {{ x }} y: {{ y }}36</UsePointer>37</template>38```3940## Type Declarations4142```ts43export interface UsePointerState extends Position {44pressure: number45pointerId: number46tiltX: number47tiltY: number48width: number49height: number50twist: number51pointerType: PointerType | null52}53export interface UsePointerOptions extends ConfigurableWindow {54/**55* Pointer types that listen to.56*57* @default ['mouse', 'touch', 'pen']58*/59pointerTypes?: PointerType[]60/**61* Initial values62*/63initialValue?: MaybeRef<Partial<UsePointerState>>64/**65* @default window66*/67target?: MaybeRef<EventTarget | null | undefined> | Document | Window68}69export interface UsePointerReturn {70pressure: Ref<number>71pointerId: Ref<number>72tiltX: Ref<number>73tiltY: Ref<number>74width: Ref<number>75height: Ref<number>76twist: Ref<number>77pointerType: Ref<PointerType | null>78x: Ref<number>79y: Ref<number>80isInside: ShallowRef<boolean>81}82/**83* Reactive pointer state.84*85* @see https://vueuse.org/usePointer86* @param options87*/88export declare function usePointer(89options?: UsePointerOptions,90): UsePointerReturn91```92