useTeleport

Commons
stable

Resolves the Vue Teleport target for overlay components. Accepts true (disable teleport — render inline), false (teleport to document.body), a CSS selector string (teleport to the matched element), or a raw Element. Creates an .origam-overlay-container div inside the target when one does not already exist, so multiple overlays sharing the same target stack correctly without polluting the host's direct children.

API

Signature

Signature TypeScript complète extraite du fichier du composable.

typescript

useTeleport is SSR-safe: it guards all document accesses behind IN_BROWSER. On the server, teleportTarget is always undefined and the caller's <Teleport :disabled="!teleportTarget"> renders inline.

API

Paramètres

Paramètres d'entrée acceptés par ce composable.

target
requis
Ref<boolean | string | Element>
Reactive teleport destination. true → returns undefined (Vue Teleport disabled, renders in-place). false → document.body. A CSS selector string → querySelector result. An Element → used directly. Returns undefined and warns if a string selector yields no match.

API

Valeurs de retour

Propriétés et méthodes exposées par l'objet retourné par le composable.

teleportTarget
The resolved .origam-overlay-container element inside the target, or undefined when teleport is disabled (target=true) or the app is running on the server (SSR). Pass directly to <Teleport :to="teleportTarget">.

Usage

Exemples

Extraits de code prêts à coller.

Overlay component with configurable teleport target

vue

Teleport inside a scoped container

vue