# Alert dialog

A dialog that needs a decision: no light dismiss, focus held until the user chooses.

Source: https://www.zazz.sh/api/primitives/alert-dialog/

## Installation

```bash
pnpm dlx zazz-ui add alert-dialog
```

Also adds `dialog`, which it depends on.

Run `zazz-ui init` first if the project has no `zazz/` folder yet.

## Examples

### Default

```html
<button
  data-ui="button"
  type="button"
  data-button-variant="destructive"
  command="show-modal"
  commandfor="alert-dialog-example-1"
>
  Delete account
</button>
<dialog
  id="alert-dialog-example-1"
  data-ui="dialog alert-dialog"
  role="alertdialog"
  aria-labelledby="alert-dialog-example-1-title"
  aria-describedby="alert-dialog-example-1-body"
  closedby="none"
>
  <div data-dialog-slot="content">
    <header
      style="
        --display: flex;
        --items: center;
        --gap: 2;
      "
      data-dialog-slot="header"
    >
      <svg style="--size: 6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
        <rect width="256" height="256" fill="none" />
        <path
          fill="currentColor"
          d="M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM120,104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm8,88a12,12,0,1,1,12-12A12,12,0,0,1,128,192Z"
        />
      </svg>
      <h2
        style="
          --font-size: var(--font-size-lg);
          --font-weight: strong;
          --font-family: var(--font-family-heading);
        "
        id="alert-dialog-example-1-title"
      >
        Are you absolutely sure?
      </h2>
    </header>
    <div style="--font-style: italic" data-dialog-slot="body" id="alert-dialog-example-1-body">
      <p>
        Alert dialogs must be closed by clicking the Cancel or Continue buttons. Changing
        <code>closedby="none"</code> to <code>closedby="any"</code> allows the user to close the
        dialog by clicking outside the dialog or pressing the Escape key.
      </p>
    </div>
    <footer data-dialog-slot="footer">
      <button data-ui="button" type="button" commandfor="alert-dialog-example-1" command="close">
        Cancel
      </button>
      <button
        data-ui="button"
        data-button-variant="destructive"
        type="button"
        commandfor="alert-dialog-example-1"
        command="close"
      >
        Delete account
      </button>
    </footer>
  </div>
</dialog>
```

## Attributes

| Attribute | Kind | Values |
| --- | --- | --- |
| `data-ui="alert-dialog"` | identity | free value |

Requires: dialog.

## Hooks

| Hook | Default | State |
| --- | --- | --- |
| `--ui-alert-dialog-accent` | `var(--color-destructive-foreground)` | — |
| `--ui-alert-dialog-shadow` | `var(--ui-dialog-shadow)` | — |
| `--ui-alert-dialog-w` | `min(45ch, 100% - var(--space-md) * 2)` | — |
