useTeleport
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
Full TypeScript signature sourced from the composable file.
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
Parameters
Input parameters accepted by this composable.
- targetrequiredRef<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
Return values
Properties and methods exposed by the composable return object.
- 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
Examples
Ready-to-paste usage snippets.
Overlay component with configurable teleport target
Teleport inside a scoped container