Dialog API
Importação
import Dialog from '@mui/material/Dialog';
// ou
import { Dialog } from '@mui/material';
Dialogs are overlaid modal paper based components with a backdrop.
Nome do componente
The nameMuiDialog
can be used when providing default props or style overrides in the theme.Propriedades
Propriedades do componente Modal também estão disponíveis.
Nome | Tipo | Padrão | Descrição |
---|---|---|---|
open* | bool | false | Control the popup` open state. |
aria-describedby | string | The id(s) of the element(s) that describe the dialog. | |
aria-labelledby | string | The id(s) of the element(s) that label the dialog. | |
BackdropComponent | elementType | styled(Backdrop, { name: 'MuiModal', slot: 'Backdrop', overridesResolver: (props, styles) => { return styles.backdrop; }, })({ zIndex: -1, }) | A backdrop component. This prop enables custom backdrop rendering. |
children | node | Dialog children, usually the included sub-components. | |
classes | object | Sobrescreve ou extende os estilos aplicados para o componente. Veja a API CSS abaixo para maiores detalhes. | |
disableEscapeKeyDown | bool | false | If true , hitting escape will not fire the onClose callback. |
fullScreen | bool | false | If true , the dialog is full-screen. |
fullWidth | bool | false | If true , the dialog stretches to maxWidth .Notice that the dialog width grow is limited by the default margin. |
maxWidth | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | false | string | '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" . | |
PaperComponent | elementType | Paper | The component used to render the body of the dialog. |
PaperProps | object | {} | Props applied to the Paper element. |
scroll | 'body' | 'paper' | 'paper' | Determine the container for scrolling the dialog. |
sx | Array<func | object | bool> | func | object | The system prop that allows defining system overrides as well as additional CSS styles. See the `sx` page for more details. | |
TransitionComponent | elementType | Fade | The component used for the transition. Follow this guide to learn more about the requirements for this component. |
transitionDuration | number | { appear?: number, enter?: number, exit?: number } | { enter: theme.transitions.duration.enteringScreen, exit: theme.transitions.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 | Props applied to the transition element. By default, the element is based on this Transition component. |
O
ref
é encaminhado para o elemento raiz.Herança
While not explicitly documented above, the props of the Modal component are also available on Dialog. You can take advantage of this to target nested components.CSS
Nome da regra | Classe global | Descrição |
---|---|---|
root | .MuiDialog-root | Estilos aplicados ao elemento raiz. |
scrollPaper | .MuiDialog-scrollPaper | Estilos aplicados para the container element se scroll="paper" . |
scrollBody | .MuiDialog-scrollBody | Estilos aplicados para the container element se scroll="body" . |
container | .MuiDialog-container | Estilos aplicados a the container element. |
paper | .MuiDialog-paper | Estilos aplicados a the Paper component. |
paperScrollPaper | .MuiDialog-paperScrollPaper | Estilos aplicados para the Paper component se scroll="paper" . |
paperScrollBody | .MuiDialog-paperScrollBody | Estilos aplicados para the Paper component se scroll="body" . |
paperWidthFalse | .MuiDialog-paperWidthFalse | Estilos aplicados para the Paper component se maxWidth=false . |
paperWidthXs | .MuiDialog-paperWidthXs | Estilos aplicados para the Paper component se maxWidth="xs" . |
paperWidthSm | .MuiDialog-paperWidthSm | Estilos aplicados para the Paper component se maxWidth="sm" . |
paperWidthMd | .MuiDialog-paperWidthMd | Estilos aplicados para the Paper component se maxWidth="md" . |
paperWidthLg | .MuiDialog-paperWidthLg | Estilos aplicados para the Paper component se maxWidth="lg" . |
paperWidthXl | .MuiDialog-paperWidthXl | Estilos aplicados para the Paper component se maxWidth="xl" . |
paperFullWidth | .MuiDialog-paperFullWidth | Estilos aplicados para the Paper component se fullWidth={true} . |
paperFullScreen | .MuiDialog-paperFullScreen | Estilos aplicados para the Paper component se fullScreen={true} . |
Você pode sobrescrever o estilo do componente usando uma dessas opções de customização:
- With a global class name.
- With a rule name as part of the component's
styleOverrides
property in a custom theme.