Modal
The Modal component lets you create dialogs, popovers, lightboxes, and other elements that force the user to take action before continuing.
Modal API
Import
import { Modal } from '@mui/base/Modal';
// or
import { Modal } from '@mui/base';
Learn about the difference by reading this guide on minimizing bundle size.
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
children* | element | - | A single child content element. |
open* | bool | - | If |
closeAfterTransition | bool | false | When set to true the Modal waits until a nested Transition is completed before closing. |
container | HTML element | func | - | An HTML element or function that returns one. The |
disableAutoFocus | bool | false | If |
disableEnforceFocus | bool | false | If |
disableEscapeKeyDown | bool | false | If |
disablePortal | bool | false | The |
disableRestoreFocus | bool | false | If |
disableScrollLock | bool | false | Disable the scroll lock behavior. |
hideBackdrop | bool | false | If |
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 Signature: function(event: object, reason: string) => void
|
onTransitionEnter | func | - | A function called when a transition enters. |
onTransitionExited | func | - | A function called when a transition has exited. |
slotProps | { backdrop?: func | object, root?: func | object } | {} | The props used for each slot inside the Modal. |
slots | { backdrop?: elementType, root?: elementType } | {} | The components used for each slot inside the Modal. Either a string to use a HTML element or a component. See Slots API below for more details. |
ref
is forwarded to the root element.To learn how to customize the slot, check out the Overriding component structure guide.
Slot name | Class name | Default component | Description |
---|---|---|---|
root | .base-Modal-root | 'div' | The component that renders the root. |
backdrop | .base-Modal-backdrop | The component that renders the backdrop. |
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
Class name | Description |
---|