Portal

Utilities
Local guide ↗ import { Portal } from "bits-ui"

Named target

Move the same child between its declaration site and a specific DOM target

Invocation site

source tree

No child here in the DOM

Named target

#portal-demo-target

The child moves without changing where the Portal is declared.

Without a to prop, Portal appends its children to document.body. The target may instead be an Element or selector string; a named target is useful when an overlay must stay inside a particular stacking or theme boundary.

Set disabled to render at the original DOM location. The same Portal implementation backs the Portal sub-component exposed by Bits UI overlays, and BitsConfig can replace its default target for an entire subtree.