# AlertDialog

> A confirmation dialog with cancel and action buttons.

- Category: [Overlays](https://tarve.dev/docs.md#overlays)
- Import: `import { AlertDialog } from "@tarve/core";`
- Props type: `AlertDialogProps`
- Source: [packages/core/src/extra-controls.ts:710](https://github.com/omarcosr/tarve/blob/main/packages/core/src/extra-controls.ts#L710)

## Usage

```tsx title="AlertDialog.tsx"
import { AlertDialog, Button } from "@tarve/core";

let open = true;

<>
  <Button variant="destructive" onClick={() => (open = true)}>
    Delete project
  </Button>
  <AlertDialog
    open={open}
    title="Delete project?"
    description="This action cannot be undone."
    actionLabel="Delete"
    actionVariant="destructive"
    onAction={() => console.log("deleted")}
    onOpenChange={(next) => {
      open = next;
    }}
  />
</>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` (required) | `boolean` | — |  |
| `title` (required) | `string` | — |  |
| `actionDisabled` | `boolean` | — |  |
| `actionLabel` | `string` | `"Continue"` |  |
| `actionVariant` | `ButtonProps["variant"]` | `"default"` |  |
| `cancelLabel` | `string` | `"Cancel"` |  |
| `closeOnEscape` | `boolean` | `false` |  |
| `description` | `string` | — |  |
| `onAction` | `() => void` | — |  |
| `onCancel` | `() => void` | — |  |
| `onOpenChange` | `(open: boolean) => void` | — |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `id`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

## Types

```ts title="ButtonProps"
interface ButtonProps extends BaseProps {
  variant?: ButtonVariant;
  size?: "sm" | "default" | "lg";
  disabled?: boolean;
  control?: Control;
  onClick?: () => void;
  onHover?: (hovered: boolean) => void;
  /**
   * Liquid Glass capsule: `true`, a variant or options. `destructive` tints it red,
   * `ghost` is clear glass without a shadow, `glass={{ tint }}` makes a prominent coloured one.
   */
  glass?: GlassProp;
}
```

Previous: [Dialog](https://tarve.dev/docs/components/Dialog.md) · Next: [Sheet](https://tarve.dev/docs/components/Sheet.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/AlertDialog · Index for agents: https://tarve.dev/llms.txt
