Brand Guide

Components

Alert dialog

A dialog that stops everything to ask for a yes or no before something is lost.

Default

Destructive

When the action deletes something, the action button takes the destructive button’s look.

Controlled

With no trigger of its own, the dialog opens from open and reports back through onOpenChange.

Best practices

  • Use an alert dialog when something would be lost and the person has to answer before going on: discarding edits, withdrawing, deleting. For anything else, use a dialog.
  • It has no close button and does not close when the page behind it is pressed. The only ways out are its two buttons and Escape.
  • It opens with focus on the cancel button, the choice that loses nothing, wherever that button sits in the content.
  • Both buttons close the dialog. Put the work in the action's onClick.
  • Name each button for what it does: "Keep editing" and "Discard changes", not "No" and "Yes".