Toggle Sidebar B
header.lightDarkMode D

Alert Dialog

Modal confirmation prompt that interrupts the user with critical content. Use for destructive actions and authorisation prompts; reach for Dialog when the modal is informational.

When to use AlertDialog vs Dialog

AlertDialog is for one-shot confirmations that need explicit acknowledgement (delete, sign out, discard changes). Dialog is the right pick for forms, multi-step flows, and informational content.

Anatomy

Import all parts and piece them together.

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

<template>
  <AlertDialog>
    <AlertDialogTrigger />
    <AlertDialogContent>
      <AlertDialogHeader>
        <AlertDialogTitle />
        <AlertDialogDescription />
      </AlertDialogHeader>
      <AlertDialogFooter>
        <AlertDialogCancel />
        <AlertDialogAction />
      </AlertDialogFooter>
    </AlertDialogContent>
  </AlertDialog>
</template>

Default

Destructive confirmation pattern with cancel and action buttons.

Controlled

Drive open state externally with v-model:open from any button.

Non-destructive

A plain confirmation that asks before a routine action.

API Reference

Props, events, and slots for each sub-component.

AlertDialog

Props

PropTypeDefaultDescription
openbooleanOpen state. Supports v-model:open.

Events

EventDescription
update:openFires when the open state changes. Enables v-model:open.

Slots

SlotDescription
defaultTrigger and content sub-components.

AlertDialogTrigger

Props

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto the child element instead of rendering a button wrapper.

Slots

SlotDescription
defaultThe element that opens the dialog.

AlertDialogContent

Props

PropTypeDefaultDescription
classstringExtra classes, merged with cn(). Forwards remaining props to reka-ui AlertDialogContent.

Events

EventDescription
escape-key-downFires when the Escape key is pressed.
open-auto-focusFires when focus moves into the content on open.
close-auto-focusFires when focus returns to the trigger on close.

Slots

SlotDescription
defaultHeader, description, and footer sub-components.

AlertDialogAction / AlertDialogCancel

Props

PropTypeDefaultDescription
asChildbooleanfalseRender the child slot without the default button wrapper.

Accessibility

Keyboard shortcuts and ARIA behavior.

Keyboard

ShortcutDescription
SpaceWhen focus is on the trigger, opens the dialog.
EnterWhen focus is on the trigger, opens the dialog.
TabCycles focus between the Cancel and Action buttons.
Shift+TabCycles focus to the previous button.
EscCloses the dialog, cancelling the action.
  • On open, focus defaults to the AlertDialogCancel button so the safe choice is selected.
  • Uses role=alertdialog and is labelled by AlertDialogTitle and described by AlertDialogDescription.
  • Must be dismissed via an explicit action; outside clicks do not close it.