Ravox KitOverlays

Alert Dialog

A question with the consequence and two ways out, for actions that can't be undone. It doesn't close on outside click, shows a loading state while the action runs and displays the error without closing. Also available as a promise: await confirm({ … }).

Settings

Variante
Toggles

Examples

With a promise: await confirm()

  • #4821 · Marina Costa
  • #4820 · Diego Alves
  • #4817 · Lia Tanaka

Type the name to confirm

Irreversible, but not destructive

Installation

The command creates components/ui/alert-dialog.tsx in your project and installs the theme with it. The file is yours: edit it as you like.

npx @ravox-ui/cli add alert-dialog

Props

PropTypeDefaultDescription
titleReactNode—The question, naming the object: "Delete the Loja Aurora project?".
descriptionReactNode—The consequence: what happens and whether it can be undone.
confirmTextstring"Confirm"The action verb ("Delete project"), never "OK".
cancelTextstring"Cancel"Text of the safe way out.
variant"default" | "destructive""default"destructive: pink button, warning icon and focus starts on Cancel.
onConfirm() => unknown | Promise<unknown>—Runs on confirm. If it returns a promise, the button loads and the dialog waits; if it fails, the error message appears and nothing closes.
confirmDisabledbooleanfalseDisables the confirm button (e.g. until the person types the name of what they are about to delete).
onCancel() => void—Called when the person backs out (button or Esc).
triggerReactElement—Element that opens the confirmation (a <Button>).
open / defaultOpen / onOpenChangeboolean / boolean / (open) => void—Controlled or not, as in Dialog.
childrenReactNode—Extra content between the description and the buttons (what will be deleted, a confirmation field).
useConfirm()(options) => Promise<boolean>—Asks for confirmation from anywhere and waits for the answer. Needs an <AlertDialogProvider> near the root.

More in Overlays