Dialog
Dialogs inform users about a task and can contain critical information, require decisions, or involve multiple tasks.Overview
Dialogs are overlaid modal paper-based components with a backdrop. They disable all app functionality when they appear and remain on screen until confirmed, dismissed, or a required action has been taken.Basic Usage
Full-Screen Dialog
For mobile devices, dialogs can be displayed full-screen:Responsive Dialog
Use thefullScreen prop with useMediaQuery for responsive behavior:
Props
Main Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | required | If true, the component is shown. |
onClose | (event: object, reason: string) => void | - | Callback fired when the dialog requests to be closed. |
fullScreen | boolean | false | If true, the dialog is full-screen. |
fullWidth | boolean | false | If true, the dialog stretches to maxWidth. |
maxWidth | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | false | 'sm' | Determine the max-width of the dialog. Set to false to disable. |
scroll | 'body' | 'paper' | 'paper' | Determine the container for scrolling the dialog. |
aria-labelledby | string | - | The id(s) of the element(s) that label the dialog. |
aria-describedby | string | - | The id(s) of the element(s) that describe the dialog. |
aria-modal | boolean | 'true' | 'false' | true | Informs assistive technologies that the element is modal. |
transitionDuration | number | { enter?: number, exit?: number } | { enter: theme.transitions.duration.enteringScreen, exit: theme.transitions.duration.leavingScreen } | The duration for the transition. |
PaperComponent | ElementType | Paper | The component used to render the body of the dialog. |
sx | SxProps<Theme> | - | System prop for defining CSS overrides. |
Slot Props
The Dialog component supports slot-based customization:slots.root- The Modal componentslots.backdrop- The Backdrop componentslots.container- The container divslots.transition- The transition component (default: Fade)slots.paper- The Paper component
slotProps to pass props to each slot:
onClose Reason
TheonClose callback receives a reason parameter that indicates why the dialog is closing:
'escapeKeyDown'- User pressed Escape key'backdropClick'- User clicked the backdrop
Accessibility
Dialogs are built with accessibility in mind:- Use
aria-labelledbyto reference the DialogTitle - Use
aria-describedbyto reference the DialogContent - The
aria-modalattribute is set totrueby default - Focus is automatically managed
CSS Classes
The component has the following CSS classes available:.MuiDialog-root- Root element.MuiDialog-paper- Paper element.MuiDialog-paperScrollPaper- Paper when scroll=‘paper’.MuiDialog-paperScrollBody- Paper when scroll=‘body’.MuiDialog-paperWidthXs- Paper with maxWidth=‘xs’.MuiDialog-paperWidthSm- Paper with maxWidth=‘sm’.MuiDialog-paperWidthMd- Paper with maxWidth=‘md’.MuiDialog-paperWidthLg- Paper with maxWidth=‘lg’.MuiDialog-paperWidthXl- Paper with maxWidth=‘xl’.MuiDialog-paperFullScreen- Paper when fullScreen=.MuiDialog-paperFullWidth- Paper when fullWidth=
Inheritance
Dialog inherits from the Modal component.Related Components
- DialogTitle - Display a dialog title
- DialogContent - Display dialog content
- DialogContentText - Display dialog text content
- DialogActions - Display dialog actions
API Reference
For complete API documentation, see:Source Location
~/workspace/source/packages/mui-material/src/Dialog/Dialog.d.ts:201