Portal

Used to render an element outside the DOM hierarchy.

Anatomy

<script>
  import { Portal } from "@saas-ui/svelte/components/portal";
</script>

<Portal>
  <div>Portal content</div>
</Portal>

<!-- Or with disabled for SSR -->
<Portal disabled>
  <div>Renders in place</div>
</Portal>

Examples

Basic Accessibility

Basic portal that renders content at the end of document.body.

Custom Container Accessibility

Portal can render into a custom container element instead of document.body.

Disabled Accessibility

When disabled, the portal renders children in place instead of teleporting them.

Props

Prop Type Default Description
disabled boolean false Whether to disable the portal and render children in place.
container any - The container element to render the portal into.