Overview
Dialog is a modal component that displays content in a centered overlay with a backdrop. It supports nested dialogs with automatic scaling animations, focus trapping, and keyboard controls.Basic usage
Components
Dialog (Root)
The root component that manages dialog state and context. Based on@base-ui/react Dialog.Root.
Controls the open state of the dialog (controlled mode).
The initial open state in uncontrolled mode.
Callback fired when the open state changes.
Whether the dialog is modal (blocks interaction with content behind it).
Dialog.Trigger
A button that opens the dialog when clicked.When true, merges props with the immediate child element instead of rendering a button.
Dialog.Content
The content container rendered in a portal with backdrop and viewport.Whether to show the close button in the top-right corner.
Props for the backdrop overlay, including a
blur property to enable backdrop blur.Custom width for the dialog content.
Toggles nested dialog animation (scaling and translation) when dialogs are stacked.
Additional CSS classes for the dialog popup.
Dialog.Header
A flex container for the dialog header, typically containing the title and description.Dialog.Title
The accessible title element for the dialog. Required for accessibility.Dialog.Description
An optional description element that provides additional context about the dialog.Dialog.Body
A flex column container for the main dialog content.Dialog.Footer
A flex container aligned to the right for action buttons.Dialog.Close
A button that closes the dialog when clicked.When true, merges props with the immediate child element instead of rendering a button.
Dialog.CloseButton
A styled close button with an X icon, automatically positioned in the top-right corner.Usage examples
Custom width dialog
Dialog with blurred backdrop
Nested dialogs
Controlled dialog
Without close button
Accessibility features
- Focus trap: Focus is trapped within the dialog when open
- ESC to close: Press Escape to close the dialog
- Focus return: Focus returns to the trigger element when closed
- ARIA labels: Proper ARIA attributes for screen readers
- Close button: Includes accessible
aria-label="Close dialog" - Modal behavior: Blocks interaction with content behind the dialog
Trigger patterns
TheDialog.Trigger component can be used in two ways:
- Default button: Renders a button element when no children are provided or
asChildis false - Custom trigger: Use
asChildprop to merge dialog trigger functionality with your own button component