Перейти к контенту

Portal API

API documentation for the React Portal component. Learn about the available props, and the CSS API.

Import

import Portal from '@material-ui/core/Portal';
// or
import { Portal } from '@material-ui/core';
You can learn about the difference by reading this guide on minimizing bundle size.

Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.

Props

NameTypeDefaultDescription
childrennodeThe children to render into the container.
containerHTML element
| func
A HTML element or function that returns one. The container will have the portal children appended to it.
By default, it uses the body of the top-level document object, so it's simply document.body most of the time.
disablePortalboolfalseThe children will be inside the DOM hierarchy of the parent component.

The component cannot hold a ref.

Demos