useLazy
Commons
stable
Controls whether a component's content has been booted into the DOM. Content is rendered on first activation and optionally destroyed when the component closes again (eager: false). Used by Dialog, Menu, Tooltip and any overlay that should avoid rendering markup before it is first opened.
API
Signature
Full TypeScript signature sourced from the composable file.
API
Parameters
Input parameters accepted by this composable.
- propsrequired{ eager: boolean }
- When eager is true the content is rendered immediately regardless of the active state, bypassing lazy mounting entirely.
- activerequiredRef<boolean>
- Reactive open/visible state of the component. The composable watches this to boot the content on first activation.
API
Return values
Properties and methods exposed by the composable return object.
- isBooted
- Flips to true the first time active becomes true, then stays true unless eager is false and onAfterLeave is called.
- hasContent
- True when the content should be in the DOM: isBooted || eager || active. Gate your content slot with v-if="hasContent".
- onAfterLeave
- Call this on the leave-transition after-leave hook. Resets isBooted to false when eager is false, removing the content from the DOM after the closing animation completes.
Usage
Examples
Ready-to-paste usage snippets.
Lazy-mount an overlay
Eager rendering (always in DOM)