# AlertDialog

> A confirmation dialog for consequential, hard-to-undo actions — fixed confirm/cancel actions, never dismissed by an outside click.

- Package: `fancy-ui-vue` (Vue 3.5+ + Tailwind CSS v4)
- Category: Overlays
- Tags: alert, dialog, confirm, destructive, overlay, modal
- Dependencies: dialog, button
- Types: `AlertDialogProps`
- Docs: https://fancy-ui.rama.app/docs/components/alert-dialog
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/vue/src/components/alert-dialog

## Import

```vue
<script setup lang="ts">
import { AlertDialog } from 'fancy-ui-vue';
</script>
```

Setup (once per project): `npm install fancy-ui-vue`, then put these lines in your main CSS file (the stylesheet imports go right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-vue/tailwind.css";
@import "fancy-ui-vue/styles.css";
```

Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in a Vue template; when one differs from the Svelte name, the Svelte name follows in parentheses. Snippets become named slots (`#default` is the default snippet), a prop the Vue port declares as a model is a `v-model:<name>` (except `ref`, exposed via `defineExpose({ ref })`: put a template ref on the component and read `.ref`) and callbacks are listeners (`onclick` is `@click`). Every component sets `inheritAttrs: false`: `class` is a declared prop, merged where the Svelte component applies it (not always the root element), and only when the props table below lists it; other attributes do not fall through unless the package README lists the component as forwarding native attributes. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/vue#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `v-model:open` (Svelte `open`) | `boolean` | `false` | Whether the alert dialog is open; bindable |
| `@open-change` (Svelte `onOpenChange`) | `(open: boolean) => void` | — | Fires whenever open changes — Confirm, Cancel, or Escape |
| `title` | `string` | — | The heading. Omitted entirely (not just visually) when not given |
| `description` | `string` | — | The warning copy under the title. Same omission rule as title |
| `confirmLabel` | `string` | `"Confirm"` | Label of the destructive action |
| `cancelLabel` | `string` | `"Cancel"` | Label of the safe action |
| `@confirm` (Svelte `onConfirm`) | `() => void` | — | Called when the destructive action is activated, before the surface closes |
| `@cancel` (Svelte `onCancel`) | `() => void` | — | Called when the safe action is activated, and also when Escape closes it |
| `initialFocus` | `HTMLElement \| null` | — | Element to focus once the surface opens; defaults to the Cancel button |
| `class` | `string` | — | Additional CSS classes for the panel |
| `ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the panel element |
| `sound` | `boolean` | `false` | Plays open on the trigger, select on a confirmed action and close on Cancel or Escape, once the user has enabled sound |

## Slots

| Slot | Description |
| --- | --- |
| `#trigger` (Svelte `trigger`) | Optional trigger; renders in place and opens the surface on activation |

## Example

```vue
<script setup lang="ts">
import { ref } from "vue";
import { AlertDialog, Button } from "fancy-ui-vue";

const status = ref("");
</script>

<template>
	<AlertDialog
		sound
		title="Delete this project?"
		description="This action is irreversible. All data will be lost."
		confirm-label="Delete"
		:on-confirm="() => (status = 'Project deleted.')"
		:on-cancel="() => (status = 'Cancelled.')"
	>
		<template #trigger>
			<Button variant="destructive">Delete project</Button>
		</template>
	</AlertDialog>

	<p v-if="status" class="text-muted-foreground mt-2 text-[12px]">{{ status }}</p>
</template>
```
