Dialog
Install an animated React dialog or AlertDialog with the shadcn CLI. Try the live demos for keyboard focus, destructive confirmations, and reduced motion.
Last updated: December 3, 2026
Installation
npx smoothui-cli add dialogFeatures
Use Dialog for tasks like editing a profile, and AlertDialog to confirm a destructive action. Both use a spring entrance, keep keyboard focus inside the modal, and skip motion when reduced motion is enabled.
Variants
Dialog
Open Edit profile in the preview. Press Tab to move between Save and the close button, or press Escape to dismiss the modal. You can also click the backdrop to close it.
Alert Dialog
In the preview, open Examples and select Alert Dialog under Scene, then open Delete account. Clicking the backdrop does not dismiss the confirmation. Cancel or Escape closes it without confirming; only the Delete button represents confirmation. The preview does not delete anything.
Accessibility
Keyboard Interactions
| Key | Description |
|---|---|
Escape | Dismisses the modal without confirming an action |
Tab | Cycles focus through focusable elements within the dialog (focus is trapped) |
Shift + Tab | Cycles focus backward through focusable elements within the dialog |
ARIA Attributes
| Attribute | Element | Purpose |
|---|---|---|
role="dialog" | Dialog content | Identifies the element as a dialog |
role="alertdialog" | AlertDialog content | Identifies the element as an alert dialog requiring user action |
aria-labelledby | Dialog/AlertDialog content | References the title for an accessible name |
aria-describedby | Dialog/AlertDialog content | References the description |
aria-modal="true" | Dialog/AlertDialog content | Indicates content behind is inert |
Screen Reader
- Focus moves to the dialog content when opened
- Focus is trapped within the dialog while open
- Focus returns to the previously focused element when the dialog closes
- The title is announced via
aria-labelledby
Reduced Motion
Enable reduced motion in your system or browser and reopen either preview. The modal and backdrop appear and disappear without the spring or fade. The controls and keyboard behavior stay the same.
Props
DialogProps
AlertDialogProps
Powered by
© 2026 SmoothUI