Skip to content
Dialog

Dialog API

The API documentation of the Dialog React component. Learn more about the properties and the CSS customization points.

import Dialog from '@material-ui/core/Dialog';

Dialogs are overlaid modal paper based components with a backdrop.

Props

Name Type Default Description
children * node Dialog children, usually the included sub-components.
classes object Override or extend the styles applied to the component. See CSS API below for more details.
disableBackdropClick bool false If true, clicking the backdrop will not fire the onClose callback.
disableEscapeKeyDown bool false If true, hitting escape will not fire the onClose callback.
fullScreen bool false If true, the dialog will be full-screen
fullWidth bool false If true, the dialog stretches to maxWidth.
maxWidth enum: 'xs', 'sm', 'md', 'lg', 'xl', false
'sm' Determine the max-width of the dialog. The dialog width grows with the size of the screen. Set to false to disable maxWidth.
onBackdropClick func Callback fired when the backdrop is clicked.
onClose func Callback fired when the component requests to be closed.

Signature:
function(event: object, reason: string) => void
event: The event source of the callback
reason: Can be:"escapeKeyDown", "backdropClick"
onEnter func Callback fired before the dialog enters.
onEntered func Callback fired when the dialog has entered.
onEntering func Callback fired when the dialog is entering.
onEscapeKeyDown func Callback fired when the escape key is pressed, disableKeyboard is false and the modal is in focus.
onExit func Callback fired before the dialog exits.
onExited func Callback fired when the dialog has exited.
onExiting func Callback fired when the dialog is exiting.
open * bool If true, the Dialog is open.
PaperComponent elementType Paper The component used to render the body of the dialog.
PaperProps object {} Properties applied to the Paper element.
scroll enum: 'body' |
 'paper'
'paper' Determine the container for scrolling the dialog.
TransitionComponent elementType Fade The component used for the transition.
transitionDuration union: number |
 { enter?: number, exit?: number }
{ enter: duration.enteringScreen, exit: duration.leavingScreen } The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object.
TransitionProps object Properties applied to the Transition element.

The ref is forwarded to the root element.

Any other properties supplied will be provided to the root element (Modal).

CSS

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.
scrollPaper Styles applied to the root element if scroll="paper".
scrollBody Styles applied to the root element if scroll="body".
container Styles applied to the container element.
paper Styles applied to the Paper component.
paperScrollPaper Styles applied to the Paper component if scroll="paper".
paperScrollBody Styles applied to the Paper component if scroll="body".
paperWidthFalse Styles applied to the Paper component if maxWidth=false.
paperWidthXs Styles applied to the Paper component if maxWidth="xs".
paperWidthSm Styles applied to the Paper component if maxWidth="sm".
paperWidthMd Styles applied to the Paper component if maxWidth="md".
paperWidthLg Styles applied to the Paper component if maxWidth="lg".
paperWidthXl Styles applied to the Paper component if maxWidth="xl".
paperFullWidth Styles applied to the Paper component if fullWidth={true}.
paperFullScreen Styles applied to the Paper component if fullScreen={true}.

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

If using the overrides key of the theme, you need to use the following style sheet name: MuiDialog.

Inheritance

The properties of the Modal component are also available. You can take advantage of this behavior to target nested components.

Notes

The component can cause issues in StrictMode.

Demos