Noctis

Alert dialog

A centred confirmation dialog that interrupts to ask a question. A trigger opens a portalled, modal panel that traps focus and blurs the page — composed from a header, a body, and a footer holding an explicit Cancel and Action. Unlike a Sheet or Dialog, a click outside never dismisses it: the user must answer.

Basic

An AlertDialog.Trigger opens the AlertDialog.Content. Compose the trigger and the footer buttons from Button through render so they inherit the button look, hover, and focus. The footer pairs an AlertDialog.Cancel (which closes without committing) with an AlertDialog.Action (which confirms). Initial focus lands on Cancel — the safe choice — so a stray Enter never confirms.

Severity tone

Set tone on AlertDialog.Contentneutral (default), danger, or warning — to mark the confirmation's severity. Tone paints a restrained, status-role cue: a leading AlertDialog.Icon recoloured to the danger/warning status colour, a colour-independent severity signal (the icon shape, not just the colour) that respects two-accent discipline — never an accent or a red-washed panel. The title stays full-contrast foreground, and the action's own danger look still comes from composing a <Button variant="danger">. info/success are intentionally absent: an alert dialog is an action gate, not a notice — route those to a Dialog.

A warning tone fits a cautionary, non-destructive gate — proceeding past a soft block rather than erasing something.

Async confirmation

Real confirmations are asynchronous — the action hits the server. Surface Base UI's actionsRef on AlertDialog.Root for an imperative handle, and confirm with a plain Button (not Action) so the dialog doesn't close optimistically: hold a pending state, render the button as loading, disable Cancel while in flight, then call actionsRef.current.close() once the request resolves (keep it open and show the error on failure). Focus stays trapped throughout.

Type to confirm

For the highest-stakes, irreversible actions, gate the destructive Action behind typing the resource's name — forcing recognition over reflex (GitHub's Danger Zone, Vercel). Keep the action disabled until a controlled input matches the required phrase. Shipped here as a composition; promote it to a part once it proves repetitive.

Multiple actions

The footer lays out its buttons by flex — stacked on a narrow screen, a row aligned to the inline-end from 40rem up — so it holds two or three actions without a new part. Order them so the primary sits at the inline-end, Cancel before it, and any secondary between.

Writing the copy

A confirmation is only as safe as its words. Be specific, not generic: name the resource and the count ("Delete 3 issues?" over "Are you sure?"). State the consequence first in the body, and close an irreversible one with "This cannot be undone." Make the button labels summarize the outcomeDelete forever / Keep editing, not OK / Cancel — and keep Cancel literally "Cancel" for consistency. Where you can, prefer an undo to a confirmation: an interruption you don't need is friction. (Sources: NN/g, Vercel Geist, WAI-ARIA APG.)

Anatomy

Compose an alert dialog from its parts. AlertDialog.Root owns the open state — it accepts every Base UI AlertDialog.Root prop, including open, defaultOpen, onOpenChange, and actionsRef (the imperative close()/unmount() handle for async flows). Always modal: focus is trapped, the page is scroll-locked, the rest of the document is inert, and — being a confirmation — it is dismissed only by Cancel, Action, or Esc, never an outside click.

  • AlertDialog.Root — owns the open state and the shared Cancel-button ref; renders no element of its own. Surfaces actionsRef.
  • AlertDialog.Trigger — opens the dialog. Style it directly or compose a Button through render.
  • AlertDialog.Content — the common composition: portal, backdrop, centring viewport, and panel in one. Props: tone (neutral default, danger, warning), size (md default, sm), backdropClassName, and any AlertDialog.Popup prop (initialFocus, finalFocus). Reach for AlertDialog.Portal + Backdrop + Viewport + Popup directly only when you need to customize the portal or backdrop wiring.
  • AlertDialog.Popup — the centred panel surface. Set tone/size here, and initialFocus / finalFocus to control where focus lands (defaults to Cancel) and returns (defaults to the trigger; set it when the trigger has unmounted).
  • AlertDialog.Header — the panel's top region for the Icon, Title, and Description, separated from the body by a divider. With an icon it becomes a gutter grid (icon at the inline-start, text beside it).
  • AlertDialog.Icon — the leading severity glyph. Wrap a Noctis Icon; it is decorative (aria-hidden) and recolours by the panel tone.
  • AlertDialog.Body — the middle region holding the message the user confirms; it reads at full contrast (never the dimmest text in the panel).
  • AlertDialog.Footer — the panel's bottom region, pinned to the base, holding the Cancel/Action pair (and an optional secondary action).
  • AlertDialog.Title + AlertDialog.Description — the panel's accessible name and supporting copy, linked to the popup via aria-labelledby and aria-describedby (the described element is the consequence message).
  • AlertDialog.Cancel — closes the dialog without committing, and is the popup's default initial-focus target. Renders a bare button, so it composes with any Button through render. Enter on it cancels — never confirms.
  • AlertDialog.Action — confirms the prompt and closes. Takes an explicit tone; composes with a Button through render.
  • AlertDialog.Close — the low-level dismiss the Cancel/Action parts are built on, for a custom action.

Every rendered part carries a data-slot (noctis-alert-dialog-trigger, noctis-alert-dialog-backdrop, noctis-alert-dialog-viewport, noctis-alert-dialog-popup, noctis-alert-dialog-close, noctis-alert-dialog-icon, noctis-alert-dialog-cancel, noctis-alert-dialog-action, noctis-alert-dialog-header, noctis-alert-dialog-body, noctis-alert-dialog-footer, noctis-alert-dialog-title, noctis-alert-dialog-description) for host-side styling — the popup also carries data-tone and data-size (and data-nested-dialog-open when stacked). Pair it with the Base UI state attributes (data-open, data-closed, data-starting-style, data-ending-style). The popup renders through Surface at elevated elevation, bordered, with the modal shadow, and the backdrop blurs the page — matching the Dialog family.

Keyboard

KeyAction
Enter / SpaceOn the trigger: open the dialog and move focus to the Cancel button.
Tab / Shift + TabMove focus to the next / previous element, trapped within the open panel.
Enter / Space (on Cancel)Cancel and close — the focused default never confirms.
EscClose the dialog without committing, and return focus to the trigger (or finalFocus).

A click on the dimmed backdrop does not close an alert dialog — a confirmation must be answered through Cancel or Action. Content behind the panel stays inert and unreachable while the dialog is open. The header icon, footer alignment, and layout mirror under RTL by construction.

Design tokens

Generated from the component's declaration — the same graph that mints the CSS, so a variable name or its resolution default can't drift. The minted tokens are the public override seam: set one on any ancestor and every alert dialog in that region retunes — e.g. .app { --noctis-alert-dialog-popup-max-inline-size: 32rem; } widens the panel beneath it. Knobs that aren't minted are reached through the part's data-slot. See Customization for the full override ladder and Tokens for the whole graph.

Token

API reference

Generated from the component's types — every prop, type, default, and description comes straight from the source. Each part gets its own table; parts that only forward to Base UI's AlertDialog list just the props they pass through. Expand a row for the full type and description.

AlertDialog.Root

No props of its own — forwards to the underlying Base UI part.

AlertDialog.Trigger

Prop

AlertDialog.Portal

Prop

AlertDialog.Backdrop

Prop

AlertDialog.Viewport

Prop

AlertDialog.Popup

Prop

AlertDialog.Content

Prop

AlertDialog.Close

Prop

AlertDialog.Cancel

Prop

AlertDialog.Action

Prop

AlertDialog.Header

Prop

AlertDialog.Body

Prop

AlertDialog.Footer

Prop

AlertDialog.Title

Prop

AlertDialog.Description

Prop

AttributeDescription
data-slotThe stable styling/testing hook every part carries.
data-openPresent on the popup and backdrop while the dialog is open.
data-closedPresent on the popup and backdrop while the dialog is closed.
data-starting-stylePresent on the popup and backdrop during the enter transition.
data-ending-stylePresent on the popup and backdrop during the exit transition.
data-toneSeverity, stamped on the popup (and mirrored on the action) — `neutral` (default), `danger`, or `warning`. Drives the restrained status-role cue (toned icon + title emphasis).
data-sizePresent on the popup: the cross-axis cap (`sm` / `md`) the width rule keys off.
data-nested-dialog-openPresent on the popup when it has a nested dialog open on top of it (drives the recede).