Skip to content
Component detail view

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

Install CLI
npx smoothui-cli add dialog

Features

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

KeyDescription
EscapeDismisses the modal without confirming an action
TabCycles focus through focusable elements within the dialog (focus is trapped)
Shift + TabCycles focus backward through focusable elements within the dialog

ARIA Attributes

AttributeElementPurpose
role="dialog"Dialog contentIdentifies the element as a dialog
role="alertdialog"AlertDialog contentIdentifies the element as an alert dialog requiring user action
aria-labelledbyDialog/AlertDialog contentReferences the title for an accessible name
aria-describedbyDialog/AlertDialog contentReferences the description
aria-modal="true"Dialog/AlertDialog contentIndicates 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

motion.dev