Vesyl UI

AlertDialog

A focused modal that interrupts the user to confirm a single action — usually a destructive one like cancelling a shipment or deleting a label. Built on base-ui Alert Dialog — focus is trapped, the action is announced as an alert, and the dialog can’t be dismissed by clicking the backdrop or pressing Escape. The only ways out are the explicit Cancel and Action buttons.

That last part is the difference from Dialog: a Dialog is a general container (forms, detail panels, multi-step flows) and is casually dismissable. Reach for AlertDialog only when you need a deliberate yes/no decision before something irreversible happens.

Compose the parts: AlertDialog (root, owns open state), AlertDialogTrigger (opens it), AlertDialogContent (the popup, renders its own backdrop), AlertDialogHeader wrapping AlertDialogTitle + AlertDialogDescription, and AlertDialogFooter holding AlertDialogCancel and AlertDialogAction. Per house convention, Cancel sits on the left and the primary/destructive action on the right.

Default

A trigger opens the dialog; the footer pairs AlertDialogCancel (defaults to the outline button variant) with a destructive AlertDialogAction. Wrap a Button in the trigger’s render prop so it inherits the styling you want.

Non-destructive confirm

Not every confirmation is a deletion. Drop the variant="destructive" on AlertDialogAction and it falls back to the primary button — right for a benign-but-consequential step like notifying a customer.

Controlled with a pending action

Drive the dialog yourself with open / onOpenChange when the confirm fires an async mutation. Call e.preventDefault() in the action’s onClick so the dialog stays open while the request runs, set loading on the action for the spinner, and disabled on Cancel — then close in onOpenChange once the work resolves.

With media

AlertDialogMedia renders a rounded badge above the title that auto-sizes its svg child. Use it for high-stakes confirmations where a warning icon adds weight; pair it with size="sm" on AlertDialogContent for the centered, two-column-footer layout.

Reference

AlertDialog

Root container. Owns open state. Extends base-ui AlertDialog.Root props.

PropTypeDefaultDescription
defaultOpenbooleanfalseInitial open state (uncontrolled)
openbooleanOpen state (controlled)
onOpenChange(open: boolean) => voidFires when the dialog opens or closes

AlertDialogTrigger

The control that opens the dialog. Extends base-ui AlertDialog.Trigger props.

PropTypeDefaultDescription
renderReactElementElement to render as the trigger, e.g. <Button variant="…" />

AlertDialogContent

The popup. Renders its own portal and backdrop, so you don’t compose those yourself. Extends base-ui AlertDialog.Popup props.

PropTypeDefaultDescription
size"sm" | "md""md"md left-aligns at width; sm centers and stacks the footer 2-up
showBackdropbooleantrueRender the dimming overlay; set false for a dialog nested in another
classNamestringMerged onto the popup

AlertDialogHeader

Layout wrapper for the title and description (and optional media). Plain div — accepts standard div props plus className.

AlertDialogTitle

The heading, announced to assistive tech. Extends base-ui AlertDialog.Title props. Required for accessibility.

AlertDialogDescription

Supporting copy under the title. Extends base-ui AlertDialog.Description props. Anchor tags inside it are auto-underlined.

AlertDialogMedia

Optional rounded icon badge shown above the title. Plain div; auto-sizes a child svg to size-8. Pass a className to tint it (e.g. bg-destructive/10 text-destructive).

AlertDialogFooter

Action row. Plain div — column-reversed on mobile, right-aligned row on desktop. Place AlertDialogCancel first (left) and AlertDialogAction last (right).

AlertDialogAction

The confirm button. Wraps Button and accepts all its props.

PropTypeDefaultDescription
variant"default" | "destructive" | "outline" | "secondary" | "ghost" | "link""default"Use "destructive" for irreversible actions
loadingbooleanfalseShows a spinner and disables the button

Does not auto-close on click in itself — closing is governed by the dialog’s open state. For a synchronous confirm, leave it; for an async one, preventDefault and close via onOpenChange.

AlertDialogCancel

The dismiss button. Wraps base-ui AlertDialog.Close rendered as a Button — closing the dialog on click is automatic.

PropTypeDefaultDescription
variantsame as Button"outline"Button styling for the cancel action
sizesame as Button"md"Button size