---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Alert dialog

A modal that asks a person to confirm or cancel before an action that cannot be undone, such as a delete, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `AlertDialog`.

## Try it

Press Delete on a list: the delete answer stays off until its name is typed exactly; Keep it or Escape leaves the list; a confirmed delete removes it from the list. Pick a look for a plain, a long or a title-only question.

The lists live in the page only; picking a look brings them back.

## When to use

- A modal that asks a person to confirm or cancel before an action that cannot be undone, such as a delete.
- Also called: confirm dialog or confirmation modal.

## When not to use

- For a form use Dialog.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Alert dialog on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-alert-dialog.json --yes
```

```text
Add the Goop Alert dialog to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import {
  AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogBody, AlertDialogFooter, AlertDialogCancel, AlertDialogAction,
  AlertDialogDestructiveAction,
} from '@/components/ui/goop/alert-dialog';
import { DestructiveButton } from '@/components/ui/goop/destructive-button';
import { Field } from '@/components/ui/goop/field';
import { TextInput } from '@/components/ui/goop/text-input';

<AlertDialog>
  <AlertDialogTrigger asChild>
    <DestructiveButton>Delete list</DestructiveButton>
  </AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Delete the Weekly notes list?</AlertDialogTitle>
      <AlertDialogDescription>
        Its 32 notes leave every view they are on, and it cannot be brought back. To confirm, type its name.
      </AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogBody>
      <Field orientation="vertical" label="Type “Weekly notes”">
        <TextInput autoComplete="off" />
      </Field>
    </AlertDialogBody>
    <AlertDialogFooter>
      <AlertDialogCancel>Keep it</AlertDialogCancel>
      <AlertDialogDestructiveAction>Delete list</AlertDialogDestructiveAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>
```

- Fits: settings (its recipe).
- width, padding, gap, text: add no class for these.

## API reference

### Options

- `open?: boolean`
- `defaultOpen?: boolean`
- `onOpenChange?: (open: boolean) => void`

- Takes every prop of Dialog but modal (its page: dialog.md)
- State: open (open / defaultOpen / onOpenChange)

### Parts

- `AlertDialogTrigger` — Wraps the control that opens the alert; put the theme's Button inside with asChild; also takes asChild?: boolean
- `AlertDialogContent` — The panel; put AlertDialogHeader in it, then AlertDialogBody when it holds a field, then AlertDialogFooter; also takes container?: HTMLElement | null
- `AlertDialogHeader` — The alert's top; put AlertDialogTitle and AlertDialogDescription in it
- `AlertDialogTitle` — The question, which names the panel
- `AlertDialogDescription` — What answering it does, which describes the panel
- `AlertDialogBody` — The alert's middle, between AlertDialogHeader and AlertDialogFooter
- `AlertDialogFooter` — The row for the two answers, AlertDialogCancel and then the confirming one
- `AlertDialogCancel` — The answer that backs out and closes the alert; it takes the focus as the alert opens; also takes type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; loading?: boolean = false; loadingLabel?: string = 'Loading'
- `AlertDialogAction` — The confirming answer, last in the footer; for a destructive one use AlertDialogDestructiveAction; also takes type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; loading?: boolean = false; loadingLabel?: string = 'Loading'
- `AlertDialogDestructiveAction` — The confirming answer where confirming deletes or cannot be undone; also takes type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; icon?: IconName = 'alert-circle'; hold?: boolean = false; onConfirm?: () => void; onFinished?: () => void; holdDuration?: number; holdHint?: string = 'Hold to confirm'; confirmLabel?: string; confirmedLabel?: string = 'Confirmed'; loading?: boolean = false; loadingLabel?: string = 'Loading'

- Required: AlertDialogTitle, inside AlertDialogContent
- data-slot values (to select a part by): alert-dialog-body, alert-dialog-content, alert-dialog-description, alert-dialog-footer, alert-dialog-header, alert-dialog-header-content, alert-dialog-title

## Keyboard

- Escape: close
- Tab: move to the next button

## Accessibility

- The part itself answers the keys above.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Dialog](/themes/trail/components/dialog): A window over the page for one focused task, such as a short form.
- [Destructive button](/themes/trail/components/destructive-button): The button for an action that deletes or cannot be undone, marked in the danger colour.
- [Field](/themes/trail/components/field): A form row that ties one control to its label, its description and its error line, as a settings row or a stacked form field.
- [Text input](/themes/trail/components/text-input): A single-line field for free words, such as a name, a title or an email.
