Default
import { PixelPortal } from '@pxlkit/ui-kit';
export function Default() {
return (
<PixelPortal>
<div>Portaled content (renders into document.body after mount)</div>
</PixelPortal>
)
}SSR-safe portal primitive: renders children inline on the server and while hydrating, then portals them into document.body or a container, keeping the focus set inside them.
import { PixelPortal } from '@pxlkit/ui-kit';| Prop | Type | Default | Description |
|---|---|---|---|
children (required) | React.ReactNode | — | Content to render in the target. |
container | HTMLElement | null | — | Target element; document.body when left out. |
disabled | boolean | — | Keep the content in place. |
ref points to <div>.
WCAG target: 2.1 AA
SSR-safe portalcontext preserved through the component treePortal content keeps its place in the component tree, so providers reach it as if it were rendered in place; in React, its events also bubble through that tree. Keyboard focus follows the document order, where the content sits in its target.
import { PixelPortal } from '@pxlkit/ui-kit';
export function Default() {
return (
<PixelPortal>
<div>Portaled content (renders into document.body after mount)</div>
</PixelPortal>
)
}import { PixelPortal } from '@pxlkit/ui-kit';
export function Default() {
return (
<PixelPortal>
<div>Portaled content (renders into document.body after mount)</div>
</PixelPortal>
)
}import { PixelPortal } from '@pxlkit/ui-kit';
export function Disabled() {
return (
<PixelPortal disabled>
<div>Rendered inline — portal disabled</div>
</PixelPortal>
)
}