ModalUnstyled API
Documentação da API para o componente React ModalUnstyled . Aprenda sobre as propriedades disponíveis e a API CSS.
Importação
import ModalUnstyled from '@mui/base/ModalUnstyled';
// ou
import { ModalUnstyled } from '@mui/base';
Modal is a lower-level construct that is leveraged by the following components:
If you are creating a modal dialog, you probably want to use the Dialog component rather than directly using Modal.
This component shares many concepts with react-overlays.
Propriedades
Propriedades do componente nativo também estão disponíveis.
Nome | Tipo | Padrão | Descrição |
---|---|---|---|
children* | element | A single child content element. ⚠️ Needs to be able to hold a ref. | |
open* | bool | false | Control the popup` open state. |
classes | object | Sobrescreve ou extende os estilos aplicados para o componente. Veja a API CSS abaixo para maiores detalhes. | |
closeAfterTransition | bool | false | When set to true the Modal waits until a nested Transition is completed before closing. |
component | elementType | The component used for the root node. Either a string to use a HTML element or a component. | |
components | { Backdrop?: elementType, Root?: elementType } | {} | The components used for each slot inside the Modal. Either a string to use a HTML element or a component. |
componentsProps | { backdrop?: func | object, root?: func | object } | {} | The props used for each slot inside the Modal. |
container | HTML element | func | A HTML element or function that returns one. The container will have the portal children appended to it.By default, it uses the body of the top-level document object, so it's simply document.body most of the time. | |
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. |
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 the onClose callback. |
disablePortal | bool | false | The children will be inside the DOM hierarchy of the parent component. |
disableRestoreFocus | bool | false | If true , the modal will not restore focus to previously focused element once modal is hidden or unmounted. |
disableScrollLock | bool | false | Disable the scroll lock behavior. |
hideBackdrop | bool | false | If true , the backdrop is not rendered. |
keepMounted | bool | false | Always keep the children in the DOM. This prop can be useful in SEO situation or when you want to maximize the responsiveness of the Modal. |
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" . |
O
ref
é encaminhado para o elemento raiz.CSS
Nome da regra | Classe global | Descrição |
---|---|---|
root | .MuiModal-root | Estilos aplicados ao elemento raiz. |
hidden | .MuiModal-hidden | Estilos aplicados para o elemento raiz se the Modal has exited. |
Você pode sobrescrever o estilo do componente usando uma dessas opções de customização:
- Com um nome de classe global.
- Com um nome de regra como parte da propriedade
styleOverrides
do componente em um tema personalizado.