# Alert Dialog

A modal confirmation surface for actions that require an explicit decision.

A modal confirmation surface for actions that require an explicit decision.

<p className="zenos-base-ui-source">
  Backed by <a href="https://base-ui.com/react/components/alert-dialog">Base UI Alert Dialog</a> for
  upstream behavior and configuration. Zenos owns the public API, styling, and composition shown on
  this page.
</p>

```tsx
import { AlertDialog } from "@zentara-co/zenos-ui";

function AlertDialogExample() {
  return (
    <AlertDialog.Root>
      <AlertDialog.Trigger variant="destructive">Delete project</AlertDialog.Trigger>
      <AlertDialog.Content>
        <AlertDialog.Header>
          <AlertDialog.Title>Delete this project?</AlertDialog.Title>
          <AlertDialog.Description>This action cannot be undone.</AlertDialog.Description>
        </AlertDialog.Header>
        <AlertDialog.Footer>
          <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
          <AlertDialog.Action variant="destructive">Delete</AlertDialog.Action>
        </AlertDialog.Footer>
      </AlertDialog.Content>
    </AlertDialog.Root>
  );
}
```

## Import

```tsx
import { AlertDialog } from "@zentara-co/zenos-ui";
```

## Confirmation patterns

Match the action tone to the consequence. Reversible actions can use the primary action, while destructive and irreversible actions should use the destructive treatment and explicit wording.

```tsx
import { AlertDialog, Stack } from "@zentara-co/zenos-ui";

function AlertDialogPatternsExample() {
  return (
    <Stack direction="row" gap="3" wrap="wrap" align="center" className="justify-center">
      <AlertDialog.Root>
        <AlertDialog.Trigger variant="primary">Archive project</AlertDialog.Trigger>
        <AlertDialog.Content>
          <AlertDialog.Header>
            <AlertDialog.Title>Archive this project?</AlertDialog.Title>
            <AlertDialog.Description>
              Members will lose access until the project is restored.
            </AlertDialog.Description>
          </AlertDialog.Header>
          <AlertDialog.Footer>
            <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
            <AlertDialog.Action>Archive</AlertDialog.Action>
          </AlertDialog.Footer>
        </AlertDialog.Content>
      </AlertDialog.Root>
      <AlertDialog.Root>
        <AlertDialog.Trigger variant="destructive">Delete project</AlertDialog.Trigger>
        <AlertDialog.Content>
          <AlertDialog.Header>
            <AlertDialog.Title>Delete this project?</AlertDialog.Title>
            <AlertDialog.Description>
              This permanently removes its data and cannot be undone.
            </AlertDialog.Description>
          </AlertDialog.Header>
          <AlertDialog.Footer>
            <AlertDialog.Cancel>Keep project</AlertDialog.Cancel>
            <AlertDialog.Action variant="destructive">Delete permanently</AlertDialog.Action>
          </AlertDialog.Footer>
        </AlertDialog.Content>
      </AlertDialog.Root>
    </Stack>
  );
}
```

## Controlled state

Control visibility when the surrounding flow needs to observe or coordinate the decision. Action and Cancel both close the modal after their handlers run.

```tsx
import { AlertDialog, Button, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function AlertDialogControlledExample() {
  const [open, setOpen] = useState(false);
  const [result, setResult] = useState("No decision");

  return (
    <Stack gap="3" align="start">
      <AlertDialog.Root open={open} onOpenChange={setOpen}>
        <AlertDialog.Trigger render={<Button variant="primary" />}>
          Revoke access
        </AlertDialog.Trigger>
        <AlertDialog.Content>
          <AlertDialog.Header>
            <AlertDialog.Title>Revoke member access?</AlertDialog.Title>
            <AlertDialog.Description>
              The member will be signed out and removed from this workspace.
            </AlertDialog.Description>
          </AlertDialog.Header>
          <AlertDialog.Footer>
            <AlertDialog.Cancel onClick={() => setResult("Cancelled")}>Cancel</AlertDialog.Cancel>
            <AlertDialog.Action variant="destructive" onClick={() => setResult("Access revoked")}>
              Revoke access
            </AlertDialog.Action>
          </AlertDialog.Footer>
        </AlertDialog.Content>
      </AlertDialog.Root>
      <Text className="text-sm text-text-subtle" aria-live="polite">
        {result}
      </Text>
    </Stack>
  );
}
```

## Nested backdrops

`AlertDialog.Content` includes a backdrop through `AlertDialog.Overlay`. The overlay defaults to `forceRender={true}` so it can render inside another dialog, including a closed sheet. This does not open the alert dialog or keep it mounted when closed. When composing the overlay yourself, pass `forceRender={false}` to use Base UI's default nested-backdrop behavior.

## Anatomy

```text
AlertDialog.Root
AlertDialog.Trigger
AlertDialog.Content
AlertDialog.Header
AlertDialog.Title
AlertDialog.Description
AlertDialog.Footer
AlertDialog.Cancel
AlertDialog.Action
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| open | boolean | — | Controlled open state. |
| defaultOpen | boolean | false | Initial uncontrolled open state. |
| onOpenChange | (open: boolean, eventDetails) => void | — | Runs when open state changes. |
| render | ReactElement \| function | — | Composes triggers and actions with another element. |
| variant / size | ButtonVariant / sm \| md \| lg | — | Styles Trigger, Action, and Cancel controls. |
| forceRender (Overlay) | boolean | true | Allows the backdrop to render inside another dialog, including a closed sheet. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

AlertDialog uses `role="alertdialog"`, traps focus, prevents casual outside dismissal, and returns focus to its trigger. Always provide a title and a description of the consequence. Use specific action text such as “Delete permanently” instead of a vague “Continue,” and make the safe cancellation path easy to identify.

Source: https://zenos-ui.pages.dev/components/alert-dialog/