Confirms an irreversible or high-stakes action. role="alertdialog", the overlay never closes it, and a danger tone puts focus on Cancel so a stray Enter can't destroy anything. Comes with an imperative useConfirm() for one-line confirmations.
Installation
The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";
Usage
import { useConfirm } from "@vamos-ui/react";
const confirm = useConfirm();
if (await confirm({ title: "Delete 3 posts?", tone: "danger", confirmLabel: "Delete" })) {
await deletePosts(ids);
}Name the action with what it does ("Delete post", "End agreement"), never "Yes" / "OK".
On mobile the buttons stack with the action on top.
Examples
Danger
tone="danger": warning icon well, danger action, initial focus on Cancel.
useConfirm (HR)
await confirm({...}) resolves true or false. Needs a ConfirmProvider (App shell includes one).
Type to confirm
requireText keeps the action disabled until the name is typed. Compared case-insensitively with the current locale's rules (Turkish İ/ı).
Async with error (PRM)
onConfirm can be async: the action shows loading, Cancel and Esc lock, and a thrown error stays inline instead of closing.
API
AlertDialog
| Prop | Type | Default |
|---|---|---|
open / defaultOpen / onOpenChangeControlled or uncontrolled open state. | Radix root props | — |
AlertDialogContent
| Prop | Type | Default |
|---|---|---|
tonedanger → icon well, danger action, focus on Cancel. default → focus on the action. | "default" | "danger" | "default" |
dismissiblefalse locks Esc (e.g. while the action runs). | boolean | true |
containerPortal target; defaults to the nearest ThemeScope. | HTMLElement | null | — |
AlertDialogHeader
| Prop | Type | Default |
|---|---|---|
titleRequired accessible name. | ReactNode | — |
descriptionWhat happens and whether it can be undone. | ReactNode | — |
iconDefaults to the warning well for tone="danger"; null removes it. | ReactNode | null | — |
AlertDialogAction
| Prop | Type | Default |
|---|---|---|
variantDefaults to danger or primary from the tone. | Button variant | — |
loadingButton loading state. | boolean | — |
keepOpenDon't close on click — close yourself when async work ends. | boolean | false |
childrenName the action with a verb ("Delete post"). | ReactNode | "Confirm" |
AlertDialogCancel
| Prop | Type | Default |
|---|---|---|
childrenDictionary confirm.cancel. | ReactNode | "Cancel" |
useConfirm() options
| Prop | Type | Default |
|---|---|---|
titleRequired. | ReactNode | — |
descriptionConsequences. | ReactNode | — |
toneAs AlertDialogContent. | "default" | "danger" | "default" |
confirmLabel / cancelLabelButton labels. | string | — |
requireTextText the user must type (locale-aware, case-insensitive). | string | — |
onConfirmAsync work; throwing keeps the dialog open and shows the message. | () => Promise<void> | void | — |
→ returnstrue on confirm, false on cancel or Esc. | Promise<boolean> | — |
Other exports
| Prop | Type | Default |
|---|---|---|
ConfirmProviderRenders the shared confirmation dialog for useConfirm(). | { labels? } | — |
ConfirmDialogThe same dialog, controlled, without the hook. | ConfirmOptions & { open, onResult } | — |
AlertDialogBody / AlertDialogFooter / AlertDialogIconBody for extra content, footer for buttons, icon well. | layout parts | — |