Modal

Accessible React modal dialog built on Radix: header icon, title, description, body, footer actions, sizes, focus trapping, and Escape to close. Inherits theme and RTL.

Modal opens a centered dialog from a trigger: header, body, and a footer of actions. It inherits theme and direction from the provider.

When to use

Use Modal for a short task that must be completed or cancelled before returning. Examples: confirming a deletion, entering a verification code, or reviewing a summary before submission. Keep it to one purpose and a few controls.

For longer secondary flows, use Drawer. For a lightweight panel anchored to a control, use Popover.

Examples

Confirmation dialog

Props

Props declared by Modal. Native attributes of the underlying element pass through.

<Modal>

PropTypeDefaultDescription
childrenReactNode
openboolean
defaultOpenboolean
onOpenChange(open: boolean) => void
modalboolean

<ModalTrigger>

PropTypeDefaultDescription
asChildboolean

<ModalClose>

PropTypeDefaultDescription
asChildboolean

<ModalContent>

PropTypeDefaultDescription
size"default" | "full"
centeredboolean
showCloseButtonbooleanRender the corner X close button. Defaults to true. Set false for action-forcing dialogs where the user must pick a footer action.
closeLabelstringLocalized label for the close button. Defaults to "Close".
forceMounttrueUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
onOpenAutoFocus(event: Event) => voidEvent handler called when auto-focusing on open. Can be prevented.
onCloseAutoFocus(event: Event) => voidEvent handler called when auto-focusing on close. Can be prevented.
deferPointerDownOutsidebooleanWhen true, a 'pointerdown' event outside of the layered element will wait for the interaction's click event before dispatching, allowing third-party code to stop propagation of later events and cancel dismissal.
onEscapeKeyDown(event: KeyboardEvent) => voidEvent handler called when the escape key is down. Can be prevented.
onPointerDownOutside(event: PointerDownOutsideEvent) => voidEvent handler called when the a pointerdown event happens outside of the DismissableLayer. Can be prevented.
onFocusOutside(event: FocusOutsideEvent) => voidEvent handler called when the focus moves outside of the DismissableLayer. Can be prevented.
onInteractOutside(event: PointerDownOutsideEvent | FocusOutsideEvent) => voidEvent handler called when an interaction happens outside the DismissableLayer. Specifically, when a pointerdown event happens outside or focus moves outside of it. Can be prevented.
asChildboolean

<ModalHeader>

PropTypeDefaultDescription
asChildboolean
iconreact.ReactNodeOptional featured icon shown above the title in a 40px SDGA disc.

<ModalTitle>

PropTypeDefaultDescription
asChildbooleanOverride the heading element (e.g. render an <h3> instead of the default <h2>).

<ModalDescription>

PropTypeDefaultDescription
asChildbooleanOverride the element (e.g. render a <div> for richer markup).

Accessibility

Modal is a Radix Dialog: it renders role="dialog" with aria-modal, traps focus while open, closes on Escape, and returns focus to the trigger on close. ModalTitle and ModalDescription are linked to the dialog so its name and purpose are announced.

The close button uses closeLabel as its accessible name, and the overlay inherits direction and theme from the provider.