Skip to main content

Function: createPortal()

createPortal(children, container?, key?): ReactPortal

Defined in: react/src/portal.ts:22

Creates a portal that renders children into a different GTK widget container.

Similar to ReactDOM.createPortal, this allows you to render a subtree into a different part of the widget tree.

When called without a container argument, the portal renders at the root level. This is useful for dialogs which don't need a parent container.

Parameters

ParameterType
childrenReactNode
container?unknown
key?string | null

Returns

ReactPortal

Example

// Render dialog at root level (no container needed)
{createPortal(<AboutDialog programName="My App" />)}

// Render into a specific container
{createPortal(<Label.Root label="This is in the Box" />, boxRef.current)}