Components
Portal
Utility component to render children elsewhere in the DOM tree
Overview
Portal is a utility component that wraps React's createPortal. Used internally by overlay components such as Dialog, Toast, and ContextMenu.
- SSR Safe — Checks
typeof documentfor safe server-side rendering - Customizable — Change the target DOM node with the
containerprop - Null safe — Returns null when there are no children
Basic Usage
import { Portal } from '@illog/ui'
// Without container, Portal renders into document.body
export function FloatingPanel() {
return (
<Portal>
<div className="floating-panel">This content is rendered in document.body.</div>
</Portal>
)
}Custom Container
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
container | Element | DocumentFragment | 'document.body' | No | Where to render the children |
children | ReactNode | - | No | Content to move |
Guidelines
- Typically used indirectly through Dialog, Toast, ContextMenu, etc., rather than directly
- Use a custom
containerwhen you need to resolve z-index conflicts