# Alert dialog

Host: Radix UI. Path: keyframes. Preset: `scale-fade`. Built against [radix-ui 1.6.7](https://www.npmjs.com/package/radix-ui/v/1.6.7).

Identical state contract to Dialog, so it needs no rule of its own.

The page this file mirrors mounts the component twice, once with the attribute and once without, so the only difference between the two is the library.

Upstream documentation: [Radix UI documentation](https://www.radix-ui.com/primitives/docs/components/alert-dialog)

The same component in other hosts: [Base UI](/base-ui/alert-dialog.md).

## Where the attribute goes

The parts this demo composes, and the value each one carries. Everything inside an animated part is that part's content, so the tree stops there.

```text
AlertDialog.Root
  AlertDialog.Trigger
  AlertDialog.Portal
    AlertDialog.Overlay  data-motion="fade"
    AlertDialog.Content  data-motion="scale-fade"
```

## How the match works

| Step | Value |
| --- | --- |
| host writes | `data-state="open" \| "closed"` |
| easeful matches | `[data-motion~="scale-fade"][data-state="closed"]` |
| what runs | `animation: motion-exit 150ms` |
| you write | `<AlertDialog.Content data-motion="scale-fade" />` |

## Every value that works here

Every value the manifest allows on this host, single presets and the pairs that compose. The first is what this component ships with. Both stages are the same component, so anything that changes between them is the attribute.

| Value | Link |
| --- | --- |
| `scale-fade` | the default |
| `fade` | [fade](/radix/alert-dialog#motion=fade) |
| `slide-up` | [slide-up](/radix/alert-dialog#motion=slide-up) |
| `fade slide-up` | [fade slide-up](/radix/alert-dialog#motion=fade%20slide-up) |
| `scale-fade slide-up` | [scale-fade slide-up](/radix/alert-dialog#motion=scale-fade%20slide-up) |

## Source

`apps/docs/components/demos/radix/alert-dialog.tsx`

```tsx
"use client"

import { AlertDialog } from "radix-ui"
import type { DemoProps } from "@/components/demos/props"

export function RadixAlertDialog({ motion }: DemoProps) {
  return (
    <AlertDialog.Root>
      <AlertDialog.Trigger className="btn">Delete branch</AlertDialog.Trigger>
      <AlertDialog.Portal>
        <AlertDialog.Overlay className="scrim" data-motion={motion && "fade"} />
        <AlertDialog.Content className="modal" data-motion={motion}>
          <AlertDialog.Title className="panel__title">Delete this branch?</AlertDialog.Title>
          <AlertDialog.Description className="panel__body">
            Same state contract as Dialog, so the same preset covers it with no extra CSS.
          </AlertDialog.Description>
          <div className="modal__actions">
            <AlertDialog.Action className="btn btn--primary">Delete</AlertDialog.Action>
            <AlertDialog.Cancel className="btn">Keep it</AlertDialog.Cancel>
          </div>
        </AlertDialog.Content>
      </AlertDialog.Portal>
    </AlertDialog.Root>
  )
}
```
