Directive catalog
All 14 directives exported by @vueuse/components 15.0.0 plus the 2 deprecated aliases. Citations are paths inside the package.
Import as named exports and use in templates (kebab-case or the imported name):
<script setup>
import { vOnClickOutside, vOnKeyStroke } from '@vueuse/components'
</script>
<template>
<div v-on-click-outside="close">...</div>
<input v-on-key-stroke:enter="submit">
</template>Binding value forms
Most directives accept either a handler or a [handler, options] tuple (each directive below cites its runtime source):
- Function:
v-xyz="handler" - Tuple:
v-xyz="[handler, options]"
All directives except vOnClickOutside are built with createDisposableDirective (dist/index.js:3), which disposes the underlying composable when the element unmounts. vOnClickOutside implements its own unmounted cleanup via a WeakMap (dist/index.js:20-38).
Catalog
vOnClickOutside (dist/index.js:21-38)
- Value:
handleror[handler, options](onClickOutsideoptions merged with the directive's capture setting) - Modifier:
.bubbleswitches from the default capture phase to bubble phase (capture = !binding.modifiers.bubble, dist/index.js:23) - Handler receives the triggering
PointerEvent
<div v-on-click-outside="[close, { ignore: [ignoreElRef], detectIframe: true }]">Modal</div>vOnKeyStroke (dist/index.js:43-54)
- Arg: key or comma-separated keys, e.g.
v-on-key-stroke:Escapeorv-on-key-stroke:a,shift(split on,, dist/index.js:44-45) - Value:
handleror[handler, options](onKeyStrokeoptions); the element is forced as the listenertarget(dist/index.js:50-53) - Handler receives the
KeyboardEvent
vOnLongPress (dist/index.js:72-75)
- Value:
handleror[handler, options](onLongPressoptions) - When the value is a plain function, directive modifiers become the long-press modifiers (dist/index.js:73)
- Handler receives the
PointerEvent
vElementBounding (dist/index.js:359-381)
- Value:
handleror[handler, options](useElementBoundingoptions) - Handler receives
{ height, bottom, left, right, top, width, x, y }on every change
vElementHover (dist/index.js:384-394)
- Value:
handleror[handler, options](useElementHoveroptions) - Handler receives a boolean hover state
vElementOverflow (dist/index.js:615-620)
- Value:
handleror[handler, options](observeMutationbool orMutationObserverInit) - Handler receives the full overflow state
{ isXOverflowed, isYOverflowed, stop, update }, fired immediately and on every change
vElementSize (dist/index.js:649-658)
- Value:
handleror[handler, initialSize, options](note: three-element tuple, dist/index.d.ts:247) - Handler receives
{ width, height }, fired immediately
vElementVisibility (dist/index.js:683-698)
- Value:
handleror[handler, options] - Without
options.controls, the handler receives a boolean. Withcontrols: true, it receives the full state includingisVisible(dist/index.d.ts:259-267)
vInfiniteScroll (dist/index.js:793-796)
- Value:
handleror[handler, options](useInfiniteScrolloptions) - Handler receives the unwrapped
useScrollstate
vIntersectionObserver (dist/index.js:799-802)
- Value:
handleror[handler, options](useIntersectionObserveroptions, includingrootMargin,threshold) - Handler receives the standard
IntersectionObserverCallbackarguments
vMouseInElement (dist/index.js:850-854)
- Value:
handleror[handler, options] - Handler receives the reactive mouse-in-element state with
stopomitted (viareactiveOmit, dist/index.js:852)
vResizeObserver (dist/index.js:1074-1077)
- Value:
handleror[handler, options](useResizeObserveroptions) - Handler receives the standard
ResizeObserverCallbackarguments
vScroll (dist/index.js:1105-1132)
- Value:
handleror[handler, options](useScrolloptions) - The handler receives the full
useScrollstate on every scroll and every scroll-end, because the directive wrapsonScrollandonStopinternally (dist/index.js:1106-1131); user-providedonScroll/onStopoptions still run
vScrollLock (dist/index.js:1135-1146)
- Value: boolean;
truelocks the element's scroll - The binding is reactive: later updates toggle the lock without recreating it
Deprecated aliases
VOnClickOutside: alias ofvOnClickOutside, marked@deprecated use vOnClickOutside instead(dist/index.d.ts:17-18)VOnLongPress: alias ofvOnLongPress, same deprecation (dist/index.d.ts:43-44)
Use the lowercase v-prefixed exports in all new code.