Modal

Modal

The API documentation of the Modal React component.

This component shares many concepts with react-overlays.

Props

Name Type Default Description
BackdropComponent union: string |
 func |
 object
Backdrop A backdrop component. This property enables custom backdrop rendering.
BackdropProps object Properties applied to the Backdrop element.
children element A single child content element.
classes object Override or extend the styles applied to the component. See CSS API below for more details.
container union: object |
 func
A node, component instance, or function that returns either. The container will have the portal children appended to it.
disableAutoFocus bool false If true, the modal will not automatically shift focus to itself when it opens, and replace it to the last focused element when it closes. This also works correctly with any modal children that have the disableAutoFocus prop.
Generally this should never be set to true as it makes the modal less accessible to assistive technologies, like screen readers.
disableBackdropClick bool false If true, clicking the backdrop will not fire any callback.
disableEnforceFocus bool false If true, the modal will not prevent focus from leaving the modal while open.
Generally this should never be set to true as it makes the modal less accessible to assistive technologies, like screen readers.
disableEscapeKeyDown bool false If true, hitting escape will not fire any callback.
disablePortal bool false Disable the portal behavior. The children stay within it's parent DOM hierarchy.
disableRestoreFocus bool false If true, the modal will not restore focus to previously focused element once modal is hidden.
hideBackdrop bool false If true, the backdrop is not rendered.
keepMounted bool false Always keep the children in the DOM. This property can be useful in SEO situation or when you want to maximize the responsiveness of the Modal.
manager object new ModalManager() A modal manager used to track and manage the state of open Modals. This enables customizing how modals interact within a container.
onBackdropClick func Callback fired when the backdrop is clicked.
onClose func Callback fired when the component requests to be closed. The reason parameter can optionally be used to control the response to onClose.

Signature:
function(event: object, reason: string) => void
event: The event source of the callback
reason: Can be:"escapeKeyDown", "backdropClick"
onEscapeKeyDown func Callback fired when the escape key is pressed, disableEscapeKeyDown is false and the modal is in focus.
onRendered func Callback fired once the children has been mounted into the container. It signals that the open={true} property took effect.
openĀ * bool If true, the modal is open.

Any other properties supplied will be spread to the root element (native element).

CSS API

You can override all the class names injected by Material-UI thanks to the classes property. This property accepts the following keys:

Name Description
root Styles applied to the root element.
hidden Styles applied to the root element if the Modal has exited.

Have a look at overriding with classes section and the implementation of the component for more detail.

If using the overrides key of the theme as documented here, you need to use the following style sheet name: MuiModal.

Demos