Skip to content
nexubDesign System
v12.7.0

Components · Overlays

Alert Dialog

StableAdded v0.0.1 · updated v5.6.0

Confirmation dialog that requires an explicit user action before proceeding.

import { AlertDialog } from '@nexub/react';
View as Markdown

Examples

Default

Type to confirm

Deleting a workspace asks for its name first.

Ask for a reason

usePrompt replaces window.prompt, with limits and a busy state.

Reason: —

Props

Props
PropTypeDefaultDescription
AlertDialog.Rootcompound—Root provider component that manages open state.
AlertDialog.Triggercompound—Element that opens the dialog on interaction.
AlertDialog.Portalcompound—Portals the overlay and content into the document body.
AlertDialog.Overlaycompound—Dimmed backdrop rendered behind the content.
AlertDialog.Contentcompound—The dialog panel containing title, description, and actions.
AlertDialog.Titlecompound—Accessible title announced to screen readers.
AlertDialog.Descriptioncompound—Supporting description text for the dialog.
AlertDialog.Actioncompound—Confirms the destructive or affirmative action and closes the dialog.
AlertDialog.Cancelcompound—Cancels the action and closes the dialog.
AlertDialog.Confirm textstring—Type-to-confirm (5.6): the Action stays disabled until this text is typed. For irreversible actions on named resources.
AlertDialog.Promptcomponent—11.2: asks for one line of text in place of window.prompt: title, label, required (default true), minLength, maxLength, validate, multiline, tone, and onSubmit (busy while its promise runs; a rejection shows its message and keeps the dialog open).
usePrompt()[prompt, element]—11.2: render element once; await prompt(options) resolves to the trimmed answer, or null when cancelled.

Design tokens

Alert Dialog reads these component tokens. Each one is unset by default and falls back to the semantic role it aliases, so nothing changes until you set it. Set one on any element to restyle every Alert Dialog below it, and leave the roles other components share alone. See the three token tiers.

Dialog and AlertDialog.

Alert Dialog design tokens
TokenAliasesNotes
--dialog-bg--color-surface-elevated—
--dialog-fg--color-on-surface—
--dialog-radius--shape-overlay—
CSS
/* One area of your app */
.checkout {
  --dialog-bg: var(--color-secondary);
}