AlertDialog

Modal confirmation dialog for destructive or irreversible actions. Traps focus and supports keyboard navigation.

Danger variant

function Example() {
  const [open, setOpen] = useState(false)
  return (
    <>
      <Button variant="destructive" onClick={() => setOpen(true)}>
        Delete account
      </Button>
      <AlertDialog
        open={open}
        onClose={() => setOpen(false)}
        onConfirm={() => deleteAccount()}
        title="Delete account?"
        description="This is permanent and cannot be undone."
        confirmLabel="Yes, delete"
        variant="danger"
      />
    </>
  )
}

Warning variant

<AlertDialog
  open={open}
  onClose={() => setOpen(false)}
  onConfirm={() => disableFeature()}
  title="Disable monitoring?"
  description="You will stop receiving alerts."
  confirmLabel="Disable"
  variant="warning"
/>

Reference

PropTypeDefaultDescription
openbooleanWhether the dialog is visible.
onClose() => voidCalled when the dialog is dismissed (Cancel, Escape, backdrop click).
onConfirm() => voidCalled when the confirm button is clicked.
titlestringDialog heading.
descriptionstringOptional explanatory text.
confirmLabelstring'Confirm'Label for the confirm button.
cancelLabelstring'Cancel'Label for the cancel button.
variant'danger' | 'warning''danger'Color scheme of the confirm button.