Portal
SSR-safe wrapper around React's createPortal. Renders children into any DOM node (default document.body) without breaking the React tree — perfect for overlays, toasts, and tooltips that need to escape an overflow: hidden ancestor.
The toast below renders into document.body — even though the trigger is nested deep in this demo card.
Usage
import { Portal } from '@bwo-ui/react';
<Portal>
<Toast />
</Portal>
// Portal into a custom container
<Portal container={() => document.getElementById('overlay-root')}>
<Modal />
</Portal>Props
| Prop | Type | Default | Description |
|---|---|---|---|
container | Element | DocumentFragment | (() => Element | DocumentFragment | null) | null | — | Target DOM node. Function is invoked once after mount. Defaults to document.body. |
disableSSR | boolean | true | Suppress render until the container resolves on the client. |