StorybookGitHub

Alert Dialog

A modal dialog that interrupts the user with important content and expects a response.

Installation

npx shadcn-vue@latest add https://vuedocs.canceydejean.dev/r/alert-dialog.json

Usage

Use alert dialog for destructive or otherwise irreversible actions that require explicit confirmation before proceeding, such as deleting a resource. Unlike Dialog, it cannot be dismissed by clicking outside or pressing escape, forcing the user to pick an explicit action.

<script setup lang="ts">
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
</script>

<template>
  <AlertDialog>
    <AlertDialogTrigger as-child>
      <Button variant="destructive">Delete account</Button>
    </AlertDialogTrigger>
    <AlertDialogContent>
      <AlertDialogHeader>
        <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
        <AlertDialogDescription>
          This action cannot be undone. This will permanently delete your account and remove your
          data from our servers.
        </AlertDialogDescription>
      </AlertDialogHeader>
      <AlertDialogFooter>
        <AlertDialogCancel>Cancel</AlertDialogCancel>
        <AlertDialogAction>Continue</AlertDialogAction>
      </AlertDialogFooter>
    </AlertDialogContent>
  </AlertDialog>
</template>

Built on reka-ui's Alert Dialog. AlertDialogAction and AlertDialogCancel reuse Button's variants for consistent styling.