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

PropTypeDefaultDescription
containerElement | DocumentFragment | (() => Element | DocumentFragment | null) | nullTarget DOM node. Function is invoked once after mount. Defaults to document.body.
disableSSRbooleantrueSuppress render until the container resolves on the client.