Dialog
Ask for focused confirmation, account choice or form input in a modal surface.
This guide covers Material UI Core with the default Emotion engine; extensions and additional demos are explicitly classified.
Use case and business boundary
Closing a dialog is not successful submission; preserve focus return, accessible title and cancellation paths.
Native composition and scope
Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Slide
Preserve native Material UI composition and types; do not substitute JGuang UI/Base UI/Radix APIs. Example entries are not extra components.
Native installation and initialization
npm install @mui/material@9.4.0 @emotion/react@11.14.0 @emotion/styled@11.14.1
Use native npm and Emotion, not an invented JGuang UI Registry URL. Place examples inside native ThemeProvider; choose CssBaseline or ScopedCssBaseline for the project. Inspect React, existing providers, lockfile and SSR first. Never overwrite files or conceal peer conflicts. This batch verified React 19.2.8; React 18 and below require matching react-is. See the included bilingual setup guide.
Practical native parameters
These selected parameters are not a flattened universal API. Preserve the native declaring owner, slot structure, nullable values and generics.
| Owner.prop | Practical role | Declaration source |
|---|---|---|
Dialog.open | Controlled native visibility; it does not fetch data or execute actions. | Dialog |
Dialog.onClose | Native request to close; reason/event signatures differ and the host updates open. | Dialog |
Dialog.fullScreen | Use a full-screen Dialog; responsive choice belongs to the host. | Dialog |
Dialog.maxWidth | Native Container/Dialog breakpoint width; false removes the native limit. | Dialog |
Runnable native examples
Machine keys select example entries, not universal variant props. Native demo JSX/data stay unchanged; JGuang-authored acceptance fixtures are explicitly labelled.
- Introduction ·
SimpleDialogDemo· upstream native demo - Alerts ·
AlertDialog· upstream native demo - Transitions ·
AlertDialogSlide· upstream native demo - Form dialogs ·
FormDialog· upstream native demo - Customization ·
CustomizedDialogs· upstream native demo - Full-screen dialogs ·
FullScreenDialog· upstream native demo - Optional sizes ·
MaxWidthDialog· upstream native demo - Responsive full-screen ·
ResponsiveDialog· upstream native demo - Confirmation dialogs ·
ConfirmationDialog· upstream native demo - Non-modal dialog ·
CookiesBanner· upstream native demo - Scrolling long content ·
ScrollDialog· upstream native demo
Explicitly unsupported additional examples
These remain in the upstream inventory, not silently skipped or presented as working previews. Additional dependency/framework acceptance is required.
- Draggable dialog ·
DraggableDialog:react-draggable
Actual usage example
Unmodified pinned native demo; copy its required local helper files together.
import * as React from 'react';
import Button from '@mui/material/Button';
import Avatar from '@mui/material/Avatar';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemAvatar from '@mui/material/ListItemAvatar';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemText from '@mui/material/ListItemText';
import DialogTitle from '@mui/material/DialogTitle';
import Dialog from '@mui/material/Dialog';
import PersonIcon from '@mui/icons-material/Person';
import AddIcon from '@mui/icons-material/Add';
import Typography from '@mui/material/Typography';
import { blue } from '@mui/material/colors';
const emails = ['username@gmail.com', 'user02@gmail.com'];
export interface SimpleDialogProps {
open: boolean;
selectedValue: string;
onClose: (value: string) => void;
}
function SimpleDialog(props: SimpleDialogProps) {
const { onClose, selectedValue, open } = props;
const handleClose = () => {
onClose(selectedValue);
};
const handleListItemClick = (value: string) => {
onClose(value);
};
return (
<Dialog onClose={handleClose} open={open}>
<DialogTitle>Set backup account</DialogTitle>
<List sx={{ pt: 0 }}>
{emails.map((email) => (
<ListItem disablePadding key={email}>
<ListItemButton onClick={() => handleListItemClick(email)}>
<ListItemAvatar>
<Avatar sx={{ bgcolor: blue[100], color: blue[600] }}>
<PersonIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary={email} />
</ListItemButton>
</ListItem>
))}
<ListItem disablePadding>
<ListItemButton
autoFocus
onClick={() => handleListItemClick('addAccount')}
>
<ListItemAvatar>
<Avatar>
<AddIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Add account" />
</ListItemButton>
</ListItem>
</List>
</Dialog>
);
}
export default function SimpleDialogDemo() {
const [open, setOpen] = React.useState(false);
const [selectedValue, setSelectedValue] = React.useState(emails[1]);
const handleClickOpen = () => {
setOpen(true);
};
const handleClose = (value: string) => {
setOpen(false);
setSelectedValue(value);
};
return (
<div>
<Typography variant="subtitle1" component="div">
Selected: {selectedValue}
</Typography>
<br />
<Button variant="outlined" onClick={handleClickOpen}>
Open simple dialog
</Button>
<SimpleDialog
selectedValue={selectedValue}
open={open}
onClose={handleClose}
/>
</div>
);
}
Example dependency boundaries
react, @mui/material/Button, @mui/material/Avatar, @mui/material/List, @mui/material/ListItem, @mui/material/ListItemAvatar, @mui/material/ListItemButton, @mui/material/ListItemText, @mui/material/DialogTitle, @mui/material/Dialog, @mui/icons-material/Person, @mui/icons-material/Add, @mui/material/Typography, @mui/material/colors, @mui/material/DialogActions, @mui/material/DialogContent, @mui/material/DialogContentText, @mui/material/Slide, @mui/material/transitions, @mui/material/TextField, @mui/material/styles, @mui/material/IconButton, @mui/icons-material/Close, @mui/material/Divider, @mui/material/AppBar, @mui/material/Toolbar, @mui/material/Box, @mui/material/FormControl, @mui/material/FormControlLabel, @mui/material/InputLabel, @mui/material/MenuItem, @mui/material/Select, @mui/material/Switch, @mui/material/useMediaQuery, @mui/material/RadioGroup, @mui/material/Radio, @mui/material/Stack, @mui/material/Unstable_TrapFocus, @mui/material/CssBaseline, @mui/material/Container, @mui/icons-material/Menu, @mui/material/Paper, @mui/material/Fade
Direct Icons/System/Utils example imports require their matching 9.4.0 packages. Relative data/helpers are part of the example closure, not extra components. Remote images and simulated operations do not supply a backend.
Pinned upstream API metadata reference
These tables retain the upstream metadata, not a newly inferred generic type system. Conditional generics, inherited props and callback details are defined by the source declarations below. Theme defaults may override metadata defaults.
Dialog
import Dialog from '@mui/material/Dialog';
import { Dialog } from '@mui/material';
Native inheritance: Modal. Parent/DOM props are not fabricated as additional own props.
| Prop | Required | Upstream metadata type / constraint | Metadata default |
|---|---|---|---|
open | yes | bool | — |
aria-describedby | no | string | — |
aria-labelledby | no | string | — |
aria-modal | no | 'false' | 'true' | bool | true |
children | no | node | — |
classes | no | object | — |
fullScreen | no | bool | false |
fullWidth | no | bool | false |
maxWidth | no | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | false | string | 'sm' |
onClose | no | func | — |
PaperComponent | no | elementType | Paper |
role | no | 'alertdialog' | 'dialog' | 'dialog' |
scroll | no | 'body' | 'paper' | 'paper' |
slotProps | no | { backdrop?: func | object, container?: func | object, paper?: func | object, root?: func | object, transition?: func | object } | {} |
slots | no | { backdrop?: elementType, container?: elementType, paper?: elementType, root?: elementType, transition?: elementType } | {} |
sx | no | Array<func | object | bool> | func | object | — |
transitionDuration | no | number | { appear?: number, enter?: number, exit?: number } | { enter: theme.transitions.duration.enteringScreen, exit: theme.transitions.duration.leavingScreen, } |
DialogTitle
import DialogTitle from '@mui/material/DialogTitle';
import { DialogTitle } from '@mui/material';
Native inheritance: Typography. Parent/DOM props are not fabricated as additional own props.
| Prop | Required | Upstream metadata type / constraint | Metadata default |
|---|---|---|---|
children | no | node | — |
classes | no | object | — |
sx | no | Array<func | object | bool> | func | object | — |
DialogContent
import DialogContent from '@mui/material/DialogContent';
import { DialogContent } from '@mui/material';
| Prop | Required | Upstream metadata type / constraint | Metadata default |
|---|---|---|---|
children | no | node | — |
classes | no | object | — |
dividers | no | bool | false |
sx | no | Array<func | object | bool> | func | object | — |
DialogContentText
import DialogContentText from '@mui/material/DialogContentText';
import { DialogContentText } from '@mui/material';
Native inheritance: Typography. Parent/DOM props are not fabricated as additional own props.
| Prop | Required | Upstream metadata type / constraint | Metadata default |
|---|---|---|---|
children | no | node | — |
classes | no | object | — |
sx | no | Array<func | object | bool> | func | object | — |
DialogActions
import DialogActions from '@mui/material/DialogActions';
import { DialogActions } from '@mui/material';
| Prop | Required | Upstream metadata type / constraint | Metadata default |
|---|---|---|---|
children | no | node | — |
classes | no | object | — |
disableSpacing | no | bool | false |
sx | no | Array<func | object | bool> | func | object | — |
Slide
import Slide from '@mui/material/Slide';
import { Slide } from '@mui/material';
Native inheritance: Transition. Parent/DOM props are not fabricated as additional own props.
| Prop | Required | Upstream metadata type / constraint | Metadata default |
|---|---|---|---|
children | yes | element | — |
addEndListener | no | func | — |
appear | no | bool | true |
container | no | HTML element | func | — |
direction | no | 'down' | 'left' | 'right' | 'up' | 'down' |
disablePrefersReducedMotion | no | bool | false |
easing | no | { enter?: string, exit?: string } | string | { enter: theme.transitions.easing.easeOut, exit: theme.transitions.easing.sharp, } |
in | no | bool | — |
timeout | no | number | { appear?: number, enter?: number, exit?: number } | { enter: theme.transitions.duration.enteringScreen, exit: theme.transitions.duration.leavingScreen, } |
Native source declarations
Declarations/imports are extracted from pinned source without flattening unions or external inheritance. Original English comments/types are source reference, not a claim of translated upstream prose. Shared types stay in their native packages.
vendor/src/Dialog/Dialog.d.ts
import * as React from 'react';
import { SxProps, Breakpoint } from '@mui/system';
import { Theme } from '../styles';
import { InternalStandardProps as StandardProps } from '../internal';
import { BackdropProps } from '../Backdrop';
import { PaperProps } from '../Paper';
import { ModalProps } from '../Modal';
import { TransitionProps } from '../transitions/types';
import { DialogClasses } from './dialogClasses';
import { CreateSlotsAndSlotProps, SlotComponentProps, SlotProps } from '../utils/types';
export interface DialogSlots {
/**
* The component that renders the transition.
* [Follow this guide](/material-ui/transitions/#transition-slots) to learn more about the requirements for this component.
* @default Collapse
*/
transition?: React.ElementType | undefined;
/**
* The component that renders the paper.
* @default Paper
*/
paper?: React.ElementType | undefined;
/**
* The component that renders the container.
*/
container?: React.ElementType | undefined;
/**
* The component that renders the backdrop.
*/
backdrop?: React.ElementType | undefined;
/**
* The component that renders the root.
*/
root?: React.ElementType | undefined;
}
export interface DialogTransitionSlotPropsOverrides {}
export interface DialogPaperSlotPropsOverrides {}
export interface DialogContainerSlotPropsOverrides {}
export interface DialogBackdropSlotPropsOverrides {}
export interface DialogRootSlotPropsOverrides {}
export type DialogSlotsAndSlotProps = CreateSlotsAndSlotProps<
DialogSlots,
{
/**
* Props forwarded to the root slot.
* By default, the available props are based on the [Modal](https://mui.com/material-ui/api/modal/#props) component.
*/
root: SlotProps<React.ElementType<ModalProps>, DialogRootSlotPropsOverrides, DialogOwnerState>;
/**
* Props forwarded to the backdrop slot.
* By default, the available props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component.
*/
backdrop: SlotProps<
React.ElementType<BackdropProps>,
DialogBackdropSlotPropsOverrides,
DialogOwnerState
>;
/**
* Props forwarded to the container slot.
* By default, the available props are based on a div element.
*/
container: SlotProps<'div', DialogContainerSlotPropsOverrides, DialogOwnerState>;
/**
* Props forwarded to the transition slot.
* By default, the available props are based on the [Fade](https://mui.com/material-ui/api/fade/#props) component.
*/
transition: SlotComponentProps<
React.ElementType<TransitionProps>,
TransitionProps & DialogTransitionSlotPropsOverrides,
DialogOwnerState
>;
/**
* Props forwarded to the paper slot.
* By default, the available props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
*/
paper: SlotProps<
React.ElementType<PaperProps>,
DialogPaperSlotPropsOverrides,
DialogOwnerState
>;
}
>;
export interface DialogProps
extends
Omit<StandardProps<ModalProps, 'children'>, 'slots' | 'slotProps'>,
DialogSlotsAndSlotProps {
/**
* The id(s) of the element(s) that describe the dialog.
*/
'aria-describedby'?: string | undefined;
/**
* The id(s) of the element(s) that label the dialog.
*/
'aria-labelledby'?: string | undefined;
/**
* Informs assistive technologies that the element is modal.
* It's added on the element with role="dialog".
* @default true
*/
'aria-modal'?: boolean | 'true' | 'false' | undefined;
/**
* Dialog children, usually the included sub-components.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DialogClasses> | undefined;
/**
* If `true`, the dialog is full-screen.
* @default false
*/
fullScreen?: boolean | undefined;
/**
* If `true`, the dialog stretches to `maxWidth`.
*
* Notice that the dialog width grow is limited by the default margin.
* @default false
*/
fullWidth?: boolean | undefined;
/**
* Determine the max-width of the dialog.
* The dialog width grows with the size of the screen.
* Set to `false` to disable `maxWidth`.
* @default 'sm'
*/
maxWidth?: Breakpoint | false | undefined;
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback.
* @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
*/
onClose?: ModalProps['onClose'] | undefined;
/**
* If `true`, the component is shown.
*/
open: ModalProps['open'];
/**
* The ARIA role for the dialog element.
* The main dialog role is `dialog`, but `alertdialog` can be used if the content of the dialog requires immediate attention.
* See https://www.w3.org/TR/wai-aria-1.2/#dialog and https://www.w3.org/TR/wai-aria-1.2/#alertdialog for more details.
* @default 'dialog'
*/
role?: 'dialog' | 'alertdialog' | undefined;
/**
* The component used to render the body of the dialog.
* @default Paper
*/
PaperComponent?: React.JSXElementConstructor<PaperProps> | undefined;
/**
* Determine the container for scrolling the dialog.
* @default 'paper'
*/
scroll?: 'body' | 'paper' | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
* @default {
* enter: theme.transitions.duration.enteringScreen,
* exit: theme.transitions.duration.leavingScreen,
* }
*/
transitionDuration?: TransitionProps['timeout'] | undefined;
}
export default function Dialog(props: DialogProps): React.JSX.Element;
export interface DialogOwnerState extends Omit<DialogProps, 'slots' | 'slotProps'> {}
vendor/src/DialogTitle/DialogTitle.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
import { Theme } from '../styles';
import { TypographyTypeMap } from '../Typography';
import { DialogTitleClasses } from './dialogTitleClasses';
export interface DialogTitleOwnProps extends Omit<TypographyTypeMap['props'], 'classes'> {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DialogTitleClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export interface DialogTitleTypeMap<
AdditionalProps = {},
RootComponent extends React.ElementType = TypographyTypeMap['defaultComponent'],
> {
props: AdditionalProps & DialogTitleOwnProps;
defaultComponent: RootComponent;
}
declare const DialogTitle: OverridableComponent<DialogTitleTypeMap>;
export type DialogTitleProps<
RootComponent extends React.ElementType = DialogTitleTypeMap['defaultComponent'],
AdditionalProps = { component?: React.ElementType | undefined },
> = OverrideProps<DialogTitleTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
vendor/src/DialogContent/DialogContent.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { Theme } from '../styles';
import { InternalStandardProps as StandardProps } from '../internal';
import { DialogContentClasses } from './dialogContentClasses';
export interface DialogContentProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>> {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DialogContentClasses> | undefined;
/**
* Display the top and bottom dividers.
* @default false
*/
dividers?: boolean | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export default function DialogContent(props: DialogContentProps): React.JSX.Element;
vendor/src/DialogContentText/DialogContentText.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { TypographyTypeMap } from '../Typography';
import { OverrideProps, OverridableComponent } from '../OverridableComponent';
import { Theme } from '../styles';
import { DialogContentTextClasses } from './dialogContentTextClasses';
export interface DialogContentTextOwnProps extends Omit<TypographyTypeMap['props'], 'classes'> {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DialogContentTextClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export interface DialogContentTextTypeMap<
AdditionalProps = {},
RootComponent extends React.ElementType = TypographyTypeMap['defaultComponent'],
> {
props: AdditionalProps & DialogContentTextOwnProps;
defaultComponent: RootComponent;
}
declare const DialogContentText: OverridableComponent<DialogContentTextTypeMap>;
export type DialogContentTextProps<
RootComponent extends React.ElementType = DialogContentTextTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<DialogContentTextTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
vendor/src/DialogActions/DialogActions.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { Theme } from '../styles';
import { InternalStandardProps as StandardProps } from '../internal';
import { DialogActionsClasses } from './dialogActionsClasses';
export interface DialogActionsProps extends StandardProps<React.HTMLAttributes<HTMLDivElement>> {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DialogActionsClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* If `true`, the actions do not have additional margin.
* @default false
*/
disableSpacing?: boolean | undefined;
}
export default function DialogActions(props: DialogActionsProps): React.JSX.Element;
vendor/src/Slide/Slide.d.ts
import * as React from 'react';
import { TransitionProps } from '../transitions/types';
export interface SlideProps extends TransitionProps {
/**
* Add a custom transition end trigger.
* Use it when you need custom logic to decide when the transition has ended.
* Note: Timeouts are still used as a fallback if provided.
*
* @param {HTMLElement} node The transitioning DOM node.
* @param {Function} done Call this when the transition has finished.
*/
addEndListener?: TransitionProps['addEndListener'] | undefined;
/**
* Perform the enter transition when it first mounts if `in` is also `true`.
* Set this to `false` to disable this behavior.
* @default true
*/
appear?: boolean | undefined;
/**
* A single child content element.
*/
children: React.ReactElement<unknown, any>;
/**
* An HTML element, or a function that returns one.
* It's used to set the container the Slide is transitioning from.
*/
container?: null | Element | ((element: Element) => Element) | undefined;
/**
* If `true`, the transition ignores `theme.motion.reducedMotion` and keeps its normal timing.
* @default false
*/
disablePrefersReducedMotion?: boolean | undefined;
/**
* Direction the child node will enter from.
* @default 'down'
*/
direction?: 'left' | 'right' | 'up' | 'down' | undefined;
/**
* The transition timing function.
* You may specify a single easing or a object containing enter and exit values.
* @default {
* enter: theme.transitions.easing.easeOut,
* exit: theme.transitions.easing.sharp,
* }
*/
easing?: TransitionProps['easing'] | undefined;
/**
* If `true`, the component will transition in.
*/
in?: TransitionProps['in'] | undefined;
ref?: React.Ref<unknown> | undefined;
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
* @default {
* enter: theme.transitions.duration.enteringScreen,
* exit: theme.transitions.duration.leavingScreen,
* }
*/
timeout?: TransitionProps['timeout'] | undefined;
}
export default function Slide(props: SlideProps): React.JSX.Element;
Post-install acceptance
Run strict types, production build and real interactions. Check keyboard labels/focus, disabled/error/read-only semantics where natively supported, both themes, narrow screens and reduced motion. Verify callbacks against the real host data; do not declare installation complete from copying a prompt. Initialization fixtures also require server HTML and warning-free hydration.
Source and license
https://github.com/mui/material-ui/tree/809a7717b4c050ba3f69b75300689f07c050a16e
MIT · @mui/material@9.4.0. Vendor originals and license are preserved. Full original upstream prose remains in vendor/docs and is not represented as fully translated.