ConfirmDialog
A confirm / cancel dialog built on Modal. onConfirm runs the action and onClose dismisses it. While busy the confirm button shows a spinner (with busyLabel) and Escape, the backdrop and close are ignored. Use tone="danger" for destructive actions; error shows a message inside the dialog.
Typed confirmation and width. confirmDisabled keeps the confirm button off until the user has done what you ask (type a phrase, tick a box), maxWidth takes a Tailwind max-w-* class for a wider dialog, and confirmVariant restyles the confirm button.
Props
openbooleanWhether the dialog is shown.
onClose() => voidCalled when cancelled or dismissed.
onConfirm() => voidCalled when the confirm button is pressed.
titleReactNodeHeader title.
tone'default' | 'danger'Default:'default'Use "danger" for destructive actions.
busybooleanDefault:falseShows a spinner on the confirm button and ignores dismissal.
confirmLabelstringDefault:'Confirm'Confirm button text.
busyLabelstringConfirm button text while busy.
cancelLabelstringDefault:'Cancel'Cancel button text.
confirmDisabledbooleanDefault:falseDisables the confirm button, e.g. until the user types a phrase.
confirmVariantButtonVariantStyle of the confirm button; defaults to "danger" for the danger tone, otherwise "default".
maxWidthstringDefault:'max-w-md'Tailwind max-width class for the dialog.
errorstringError message shown in the dialog.
childrenReactNodeContent.
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | – | Whether the dialog is shown. |
onClose | () => void | – | Called when cancelled or dismissed. |
onConfirm | () => void | – | Called when the confirm button is pressed. |
title | ReactNode | – | Header title. |
tone | 'default' | 'danger' | 'default' | Use "danger" for destructive actions. |
busy | boolean | false | Shows a spinner on the confirm button and ignores dismissal. |
confirmLabel | string | 'Confirm' | Confirm button text. |
busyLabel | string | – | Confirm button text while busy. |
cancelLabel | string | 'Cancel' | Cancel button text. |
confirmDisabled | boolean | false | Disables the confirm button, e.g. until the user types a phrase. |
confirmVariant | ButtonVariant | – | Style of the confirm button; defaults to "danger" for the danger tone, otherwise "default". |
maxWidth | string | 'max-w-md' | Tailwind max-width class for the dialog. |
error | string | – | Error message shown in the dialog. |
children | ReactNode | – | Content. |