Modal
The Modal component lets you create dialogs, popovers, lightboxes, and other elements that force the user to take action before continuing.
useModal API
Import
import { unstable_useModal as useModal } from '@mui/base/unstable_useModal';
// or
import { unstable_useModal as useModal } from '@mui/base';Parameters
Type:
React.AriaAttributes['aria-hidden']When set to true the Modal waits until a nested Transition is completed before closing.
Type:
booleanDefault:
falseAn 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.
Type:
PortalProps['container']If true, hitting escape will not fire the onClose callback.
Type:
booleanDefault:
falseCallback fired when the component requests to be closed.
The reason parameter can optionally be used to control the response to onClose.
Type:
{
bivarianceHack(event: {}, reason: 'backdropClick' | 'escapeKeyDown'): void
}['bivarianceHack']Return value
If true, the exiting transition finished (to be used for unmounting the component).
Type:
booleanResolver for the backdrop slot's props.
Type:
<TOther extends EventHandlers = {}>(externalProps?: TOther) => UseModalBackdropSlotProps<TOther>Resolver for the root slot's props.
Type:
<TOther extends EventHandlers = {}>(externalProps?: TOther) => UseModalRootSlotProps<TOther>Resolver for the transition related props.
Type:
<TOther extends EventHandlers = {}>(externalProps?: TOther) => { onEnter: () => void; onExited: () => void }