Veil UI
Components

Alert Dialog

A modal confirmation that interrupts the user for destructive actions.

Installation

$ npx veil-ui@latest add alert-dialog

Usage

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog";

<AlertDialog>
  <AlertDialogTrigger asChild>
    <button type="button">Delete</button>
  </AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Delete this workspace?</AlertDialogTitle>
      <AlertDialogDescription>This cannot be undone.</AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancel</AlertDialogCancel>
      <AlertDialogAction>Delete</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>;

Examples

Basic

Destructive

API reference

Subcomponents

  • AlertDialog, AlertDialogTrigger, AlertDialogContent — root, trigger and portalled modal.
  • AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter — layout and required labelling.
  • AlertDialogAction, AlertDialogCancel — pre-styled destructive and outline buttons.

Accessibility

  • Radix Alert Dialog uses role="alertdialog", traps focus and requires an explicit action or cancel.
  • Escape and overlay clicks cancel; the title labels the dialog and the description is announced with it.
  • Use it only for consequential confirmations, not informational dialogs.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add alert-dialog --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { AlertDialogAction } from "reka-ui";
import { computed } from "vue";

import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";

const props = defineProps<{ class?: string }>();

const classes = computed(() =>
  cn(buttonVariants({ variant: "destructive" }), props.class),
);
</script>

<template>
  <AlertDialogAction
    data-slot="alert-dialog-action"
    :class="classes"
  >
    <slot />
  </AlertDialogAction>
</template>

On this page