Alert dialog
Alert dialog component to confirm destructive or important actions, with tones, a loading state and a safe default focus.
How to use it
Run npx @blossomui/react add alert-dialog, or copy src/components/UI/AlertDialog/AlertDialog.tsx into your React project and import it.
import { AlertDialog } from './components/ui/AlertDialog'Props
AlertDialogProps
| Prop | Type | Description |
|---|---|---|
| open (required) | boolean | |
| onClose (required) | () => void | Called when the user cancels: the cancel button, Escape or, with `closeOnBackdrop`, a click outside. |
| onConfirm (required) | () => void | Called when the user confirms. The dialog does not close by itself: close it here, after the work is done. |
| title (required) | string | |
| children | ReactNode | What is going to happen and what it means. |
| tone | AlertDialogTone | `danger` for deleting something, `warning` for something that cannot be undone easily. |
| confirmLabel | string | Text of the confirm button. |
| cancelLabel | string | Text of the cancel button. |
| loading | boolean | Shows a spinner in the confirm button and blocks the dialog while the work is done. |
| icon | ReactNode | Icon shown above the title. A default one is drawn for each tone. |
| confirmColor | ButtonColor | (string & {}) | Color of the confirm button. By default it follows `tone`. |
| closeOnBackdrop | boolean | Close when the user clicks outside. Off by default: an alert asks for an answer. |