Dialog

Animated modal dialog with title, description, close button, and focus trap. Includes an AlertDialog variant that requires explicit user action.

Open in v0

Last updated: March 29, 2026

Installation

npx smoothui-cli add dialog

Features

  • Controlled open and onOpenChange props
  • Title, description, and footer slots
  • Close button with configurable visibility
  • Focus trap within the dialog
  • Escape key to dismiss (Dialog only)
  • Backdrop click to dismiss (Dialog only)
  • AlertDialog variant that requires explicit action (no Escape dismiss)
  • Spring animation with reduced motion support

Accessibility

Keyboard Interactions

KeyDescription
EscapeCloses the dialog (Dialog only — AlertDialog ignores Escape)
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

This component respects the prefers-reduced-motion media query via useReducedMotion from Motion. When reduced motion is preferred, all scale, fade, and zoom animations are disabled instantly.

Props

DialogProps

AlertDialogProps