Skip to main content
Vuetify0 is now in alpha!
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

usePresence

Animation-agnostic mount lifecycle management.

Usage

The usePresence composable implements a state machine that controls when content should be in the DOM. It handles lazy mounting, enter/exit timing, and cleanup — without opinion on how animation happens.

ts
import { usePresence } from '@vuetify/v0'
import { shallowRef } from 'vue'

const isOpen = shallowRef(false)

const { isMounted, isPresent, isLeaving, state, done } = usePresence({
  present: isOpen,
  lazy: true,
  immediate: false,
})

// isMounted — controls v-if (true during mounted, present, and leaving)
// state — 'unmounted' | 'mounted' | 'present' | 'leaving'
// done() — call when exit animation finishes

Options

OptionTypeDefaultNotes
presentMaybeRefOrGetter<boolean>Required. Drives visibility — when truthy, content enters; when falsy, begins leaving
lazybooleanfalseDelay first mount until present is true for the first time
immediatebooleantrueAuto-resolve the leaving state on the next tick if done() is not called. Set to false for JS-driven animations that need full timing control

Architecture

Reactivity

PropertyTypeDescription
stateRef<PresenceState>Current lifecycle state
isMountedRef<boolean>Whether content should be in the DOM
isPresentRef<boolean>Whether content is logically active
isLeavingRef<boolean>Whether an exit is in progress
done() => voidSignal that exit animation is complete

Examples

FAQ

API Reference

The following API details are for the usePresence composable.
Was this page helpful?

Ctrl+/