Portal

Portal displays content in outside of the DOM hierarchy.

1
import { Portal } from '@cerberus-design/react'

When to use

When you need display a component outside of the parent it is contained within.

Usage

preview mode

When not to use

Portals should only be used for alert/dialog level components. Anything else should try to achieve this without the use of a portal.

API

export interface PortalProps {
container?: Element | DocumentFragment
key?: null | string
}
define function Portal(props: PropsWithChildren<PortalProps>): ReactPortal | null

Props

The Portal component accepts the following props:

NameDefaultDescription
containerdocument.bodyThe mounted element to place the children contents within.
keynullA unique key to attached to the Portal instance.

On this page