# Alert dialog

Confirm an action with clear cancel and confirm controls.

Access: pro. Category: Feedback. Kind: composite.

## When to use

- Use it when a page needs confirm an action with clear cancel and confirm controls.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose alert instead when inline notices with icons, actions and optional dismissal is the actual interface need, rather than alert dialog.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Alert dialog

```sh
npx shadcn@latest add @tidal-pro/alert-dialog
```

Stylesheets: `components/ui/tidal.css`, `components/ui/alert-dialog.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/alert-dialog.css";
import{TidalAlertDialog}from"./components/ui/alert-dialog";
export default(p:Parameters<typeof TidalAlertDialog>[0])=><div className="tidal-scope"><TidalAlertDialog {...p}/></div>;
```

## Structured props

- `TidalAlertDialog.cancelLabel: ReactNode`: Required cancel label value accepted by this exported component.
- `TidalAlertDialog.confirmLabel: ReactNode`: Required confirm label value accepted by this exported component.
- `TidalAlertDialog.description: ReactNode`: Required description value accepted by this exported component.
- `TidalAlertDialog.onCancel: (event: TidalAlertDialogCancelEvent, reason: TidalAlertDialogCancelReason) => void`: Callback invoked when the cancel interaction is proposed.
- `TidalAlertDialog.onConfirm: (event: ReactMouseEvent<HTMLButtonElement>) => void`: Callback invoked when the confirm interaction is proposed.
- `TidalAlertDialog.onOpenChange: (open: boolean) => void`: Callback invoked when the open change interaction is proposed.
- `TidalAlertDialog.open: boolean`: Required open value accepted by this exported component.
- `TidalAlertDialog.title: ReactNode`: Required title value accepted by this exported component.
- `TidalAlertDialog.trigger: ReactElement<unknown, string | JSXElementConstructor<any>>`: Required trigger value accepted by this exported component.
- `TidalAlertDialog.actionsLabel?: string | undefined` (default "Confirmation actions"): Optional actions label value accepted by this exported component.
- `TidalAlertDialog.busy?: boolean | undefined` (default false): Optional busy value accepted by this exported component.
- `TidalAlertDialog.busyLabel?: ReactNode` (default "Working…"): Optional busy label value accepted by this exported component.
- `TidalAlertDialog.cancelButtonProps?: TidalAlertDialogButtonProps | undefined`: Optional cancel button props value accepted by this exported component.
- `TidalAlertDialog.cancelButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional cancel button ref value accepted by this exported component.
- `TidalAlertDialog.cancelDisabled?: boolean | undefined` (default false): Optional cancel disabled value accepted by this exported component.
- `TidalAlertDialog.confirmButtonProps?: TidalAlertDialogButtonProps | undefined`: Optional confirm button props value accepted by this exported component.
- `TidalAlertDialog.confirmButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional confirm button ref value accepted by this exported component.
- `TidalAlertDialog.confirmDisabled?: boolean | undefined` (default false): Optional confirm disabled value accepted by this exported component.
- `TidalAlertDialog.contentProps?: Omit<Omit<Dialog.DialogContentProps & RefAttributes<HTMLDivElement>, "ref">, "role" | "aria-describedby" | "aria-labelledby" | "children"> | undefined`: Optional content props value accepted by this exported component.
- `TidalAlertDialog.detail?: ReactNode`: Optional detail value accepted by this exported component.
- `TidalAlertDialog.dir?: "ltr" | "rtl" | undefined` (default "ltr"): Optional dir value accepted by this exported component.
- `TidalAlertDialog.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalAlertDialog.escapeCancels?: boolean | undefined` (default true): Optional escape cancels value accepted by this exported component.
- `TidalAlertDialog.outsidePointerCancels?: boolean | undefined` (default false): Optional outside pointer cancels value accepted by this exported component.
- `TidalAlertDialog.overlayProps?: Omit<Omit<Dialog.DialogOverlayProps & RefAttributes<HTMLDivElement>, "ref">, "children"> | undefined`: Optional overlay props value accepted by this exported component.
- `TidalAlertDialog.portalContainer?: HTMLElement | null | undefined`: Optional portal container value accepted by this exported component.
- `TidalAlertDialog.theme?: "light" | "dark" | undefined` (default "light"): Optional theme value accepted by this exported component.
- `TidalAlertDialog.tone?: "default" | "danger" | undefined` (default "default"): Optional tone value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/alert-dialog.tsx) | [Manifest](https://tidalui.com/examples/alert-dialog.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useRef, useState } from "react";

import { TidalAlertDialog } from "./components/ui/alert-dialog";

import "./components/ui/alert-dialog.css";



const tidalExampleStyles = ".tidal-scope .alert-dialog-demo,\n.tidal-scope .alert-dialog-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .alert-dialog-demo {\n  display: grid;\n  width: min(100%, 620px);\n  min-width: 0;\n  gap: 12px;\n  margin-inline: auto;\n}\n\n.tidal-scope .alert-dialog-demo-card {\n  display: flex;\n  min-width: 0;\n  align-items: center;\n  justify-content: space-between;\n  gap: 22px;\n  padding: 20px;\n  color: var(--t-ink);\n  background: var(--t-surface);\n  border: 1px solid var(--t-border);\n  border-radius: 18px;\n  box-shadow: 0 22px 48px -42px #0000008f;\n}\n\n.tidal-scope .alert-dialog-demo-card > div {\n  display: grid;\n  min-width: 0;\n  gap: 4px;\n}\n\n.tidal-scope .alert-dialog-demo-card span {\n  color: var(--t-muted);\n  font-size: 11px;\n  font-weight: 720;\n  letter-spacing: 0.09em;\n  line-height: 1.35;\n  text-transform: uppercase;\n}\n\n.tidal-scope .alert-dialog-demo-card strong {\n  font-size: 18px;\n  font-weight: 650;\n  letter-spacing: -0.025em;\n  line-height: 1.25;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .alert-dialog-demo-card small {\n  color: var(--t-muted);\n  font-size: 12px;\n  line-height: 1.4;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .alert-dialog-demo-card[data-removed=\"true\"] {\n  border-style: dashed;\n}\n\n.tidal-scope .alert-dialog-demo-trigger {\n  display: inline-flex;\n  min-width: 0;\n  min-height: 44px;\n  flex: 0 0 auto;\n  align-items: center;\n  justify-content: center;\n  padding: 10px 15px;\n  color: var(--t-surface);\n  background: var(--t-ink);\n  border: 1px solid var(--t-ink);\n  border-radius: 10px;\n  font: inherit;\n  font-size: 13px;\n  font-weight: 680;\n  line-height: 1.25;\n  text-align: center;\n  overflow-wrap: anywhere;\n  cursor: pointer;\n  transition:\n    color 140ms var(--t-ease-out),\n    background 140ms var(--t-ease-out),\n    transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .alert-dialog-demo-trigger:hover {\n  color: var(--t-ink);\n  background: var(--t-surface);\n}\n\n.tidal-scope .alert-dialog-demo-trigger:active {\n  transform: scale(0.975);\n}\n\n.tidal-scope .alert-dialog-demo-trigger:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n\n.tidal-scope .alert-dialog-demo-status {\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 12px;\n  line-height: 1.5;\n  text-align: center;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .alert-dialog-demo-detail {\n  display: grid;\n  grid-template-columns: repeat(2, minmax(0, 1fr));\n  gap: 12px;\n  margin: 0;\n}\n\n.tidal-scope .alert-dialog-demo-detail > div {\n  min-width: 0;\n}\n\n.tidal-scope .alert-dialog-demo-detail dt {\n  font-size: 10px;\n  font-weight: 720;\n  letter-spacing: 0.08em;\n  text-transform: uppercase;\n}\n\n.tidal-scope .alert-dialog-demo-detail dd {\n  margin: 3px 0 0;\n  color: var(--t-ink);\n  font-size: 12px;\n  font-weight: 620;\n  overflow-wrap: anywhere;\n}\n\n@container preview-stage (max-width: 440px) {\n  .tidal-scope .alert-dialog-demo-card {\n    display: grid;\n    gap: 16px;\n    padding: 16px;\n  }\n\n  .tidal-scope .alert-dialog-demo-trigger {\n    width: 100%;\n    font-size: 16px;\n  }\n\n  .tidal-scope .alert-dialog-demo-status {\n    font-size: 14px;\n  }\n}\n\n@media (max-width: 440px) {\n  .tidal-scope .alert-dialog-demo-card {\n    display: grid;\n    gap: 16px;\n    padding: 16px;\n  }\n\n  .tidal-scope .alert-dialog-demo-trigger {\n    width: 100%;\n    font-size: 16px;\n  }\n\n  .tidal-scope .alert-dialog-demo-status {\n    font-size: 14px;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .alert-dialog-demo-trigger {\n    transition-duration: 0.01ms;\n  }\n\n  .tidal-scope .alert-dialog-demo-trigger:active {\n    transform: none;\n  }\n}";

export function AlertDialogDemo({
  theme = "light",
}: {
  theme?: "light" | "dark";
}) {
  const [open, setOpen] = useState(false);
  const [removed, setRemoved] = useState(false);
  const [status, setStatus] = useState("The sample report is available.");
  const triggerRef = useRef<HTMLButtonElement>(null);

  return (
    <section
      className="alert-dialog-demo"
      aria-label="Report confirmation preview"
    >
      <div
        className="alert-dialog-demo-card"
        data-removed={removed || undefined}
      >
        <div>
          <span>Weekly report</span>
          <strong>
            {removed ? "Sample report removed" : "October 14 report"}
          </strong>
          <small>
            {removed ? "Ready to restore" : "12 sections · Edited today"}
          </small>
        </div>

        <TidalAlertDialog
          theme={theme}
          open={open}
          onOpenChange={setOpen}
          trigger={
            <button
              ref={triggerRef}
              type="button"
              className="alert-dialog-demo-trigger"
              onClick={(event) => {
                if (!removed) return;
                event.preventDefault();
                setRemoved(false);
                setStatus("The sample report was restored locally.");
              }}
            >
              {removed ? "Restore sample report" : "Delete sample report"}
            </button>
          }
          title="Delete this report?"
          description="This removes the report from the local preview. The action cannot be undone inside the open dialog."
          detail={
            <dl className="alert-dialog-demo-detail">
              <div>
                <dt>Report</dt>
                <dd>October 14 report</dd>
              </div>
              <div>
                <dt>Contents</dt>
                <dd>12 sample sections</dd>
              </div>
            </dl>
          }
          cancelLabel="Keep report"
          confirmLabel="Delete report"
          tone="danger"
          escapeCancels
          outsidePointerCancels={false}
          onCancel={(_event, reason) => {
            setOpen(false);
            setStatus(
              reason === "escape-key"
                ? "Deletion cancelled with Escape."
                : reason === "outside-pointer"
                  ? "Deletion cancelled from outside the dialog."
                  : "The sample report was kept.",
            );
          }}
          onConfirm={() => {
            setRemoved(true);
            setOpen(false);
            setStatus("The sample report was removed locally.");
          }}
        />
      </div>

      <p className="alert-dialog-demo-status" role="status" aria-live="polite">
        {status} Changes stay in this preview.
      </p>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <AlertDialogDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Escape dismisses the open overlay where the underlying primitive supports dismissal."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

open and onOpenChange form the required controlled visibility contract. trigger is a consumer-owned React element wrapped with Radix asChild, so its native attributes and ref remain available and focus returns to it when the dialog closes. Required title and description label an explicit alertdialog through generated stable IDs; optional detail preserves numeric zero. cancelLabel, confirmLabel and optional busyLabel are consumer content. onCancel receives the native cancel, Escape or pointer-outside event plus its reason; onConfirm receives the native button event. Native button handlers run first and prevention suppresses the higher callback. busy, disabled and per-action disabled props disable the appropriate native actions; busy also exposes aria-busy. Initial focus selects the enabled cancel action, then the dialog container when cancel is unavailable, and never selects the confirm action by default. escapeCancels defaults true; outsidePointerCancels defaults false. Both channels remain open until the consumer updates open, and busy or disabled ignores them. tone, theme, dir, portalContainer and actionsLabel configure presentation. Cancel and confirm prop bags preserve native form/button attributes while excluding conflicting disabled and ARIA-disabled values; separate refs target each button. Overlay and content prop bags forward compatible native Radix attributes and caller handlers while the component owns role, labels and children. The forwarded component ref targets the dialog content. Consumers own every confirmation effect, pending state and focus destination after external state changes; the component performs no mutation, request, navigation, storage or backend action.
