Portal
stableRenders children into document.body or a custom container.
Basic usage
Container:
Content is portalled into the container div aboveExamples
Inline container portal
Portal renders children inside a specific DOM node — here visible within the preview.
Container:
Body portal
Without a container, Portal renders into document.body — useful for modals and overlays.
Content portalled to document.body exits this preview container — useful for z-index isolation.
Custom container
Portal renders into document.body by default; pass container for a specific node.
Container:
Features
- SSR-safe mount.
- Custom container support.
Installation
bash
pnpm dlx structyl add portalAPI Reference
Portal
Portal utility.
| Prop | Type | Default |
|---|---|---|
| container | Element | DocumentFragment | nullCustom target container. | — |
| children | React.ReactNodePortaled content. | — |