Skip to content
esc

Dialog

Overlayshadcn/ui

A centered panel over a scrim that asks for a decision or a short task before going back to the page: 'Delete this card?', 'Rename project'.

When to use

  • Put the main action last in DialogFooter; use variant='destructive' for deletions.
  • Keep it to one decision or a form of up to three fields.
  • Wrap the cancel button in DialogClose asChild.
  • Don't open a dialog from a dialog.
  • Don't use it for long forms or on mobile for menus; use Sheet side='bottom'.
  • Don't use it for a confirmation that needs no choice; use Toast.

Accessibility

Role
dialog (aria-modal)
Keyboard
Focus moves inside on open and returns to the trigger on close. Tab is trapped inside. Esc closes.
Notes
DialogTitle is required; hide it with sr-only if the design has no visible title.

Props

  • open / onOpenChange

    boolean / (open: boolean) => void

    Controlled state, e.g. to close it after a request succeeds.

  • showCloseButton= true

    boolean

    On DialogContent. Hide the X only when a footer button closes it.

Prompt for your agent

Use the UnbuiltUI Dialog. Call unbuilt_get_component("Dialog") first and follow its spec: variants, states, usage rules and accessibility.

unbuilt_get_component returns

0 variants1 state2 props6 usage rules4 a11y notes6 tokens1 example

Add it with shadcn

$npx shadcn add https://unbuiltui.com/r/dialog.json

Tokens · 6

bg.raisedfg.defaultfg.mutedradius.lgshadow.raisedmotion.fast