Alert Dialog
Destructive action confirmation dialog with explicit cancel and action controls.
pnpm dlx @glinui/cli@latest add alert-dialogDelete this project
Removes lumen-web, its deployments and all stored analytics.
Installation
pnpm dlx @glinui/cli@latest add alert-dialogPrefer the package?
Usage
Overlay demos on this page render inside the preview stage so they stay contained. In your app they portal to the document body as usual.
Discard draft
A small alert dialog for a reversible but lossy action.
"use client"
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, Button, Input, Label} from "@glinui/ui"
const CARD = "mx-auto w-full rounded-2xl border border-[var(--line-soft)] bg-[var(--surface-1)] p-5 [box-shadow:var(--elev-1)]"
export function AlertDiscardExample() { return ( <div className={`${CARD} max-w-md`}> <Label htmlFor="draft-title">Post title</Label> <Input id="draft-title" className="mt-2" defaultValue="Launch notes for v2.4" /> <div className="mt-4 flex justify-end gap-2"> <AlertDialog> <AlertDialogTrigger asChild><Button variant="ghost">Discard draft</Button></AlertDialogTrigger> <AlertDialogContent size="sm"> <AlertDialogHeader> <AlertDialogTitle>Discard this draft?</AlertDialogTitle> <AlertDialogDescription>Your unsaved edits will be lost.</AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter> <AlertDialogCancel>Keep editing</AlertDialogCancel> <AlertDialogAction>Discard</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent> </AlertDialog> <Button>Publish</Button> </div> </div> )}Variants
Every look of the shared vocabulary: glinr (the default), plain (shadcn), solid, soft, outline, ghost, gradient and glass. Omit `variant` to follow the ambient design style.
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, Button } from "@glinui/ui"
const variants = ["glinr", "plain", "solid", "soft", "outline", "ghost", "gradient", "glass"] as const
export function Demo() { return ( <div className="flex flex-wrap gap-2"> {variants.map((variant) => ( <AlertDialog key={variant}> <AlertDialogTrigger asChild><Button size="sm" variant="outline">{variant}</Button></AlertDialogTrigger> <AlertDialogContent variant={variant} size="sm"> <AlertDialogHeader> <AlertDialogTitle>{variant} alert</AlertDialogTitle> <AlertDialogDescription>Confirm to continue.</AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter> <AlertDialogCancel>Cancel</AlertDialogCancel> <AlertDialogAction>Confirm</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent> </AlertDialog> ))} </div> )}Glass (opt-in)
Glass is opt-in and needs a colourful or photographic backdrop to read as frosted. Pick one in the stage header.
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, Button} from "@glinui/ui"
export function Demo() { return ( <AlertDialog> <AlertDialogTrigger asChild> <Button variant="outline">Archive workspace</Button> </AlertDialogTrigger> <AlertDialogContent variant="glass" size="sm"> <AlertDialogHeader> <AlertDialogTitle>Archive workspace?</AlertDialogTitle> <AlertDialogDescription> Members will lose write access until you restore the workspace. </AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter> <AlertDialogCancel>Not now</AlertDialogCancel> <AlertDialogAction variant="glass">Archive</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent> </AlertDialog> )}Accessibility
- Built on Radix Alert Dialog with focus trap and screen reader semantics.
- Use a clear, explicit `AlertDialogTitle` and concise `AlertDialogDescription` for destructive actions.
- Focus returns to the trigger after close.
- Uses `role="alertdialog"` semantics through Radix.
- Focus is trapped inside the dialog while open.
- Keep destructive copy explicit in `AlertDialogTitle` and `AlertDialogDescription`.
Keyboard Interactions
| Key | Action |
|---|---|
| Escape | Close the alert dialog. |
| Tab / Shift+Tab | Cycle focus between actions. |
| Enter / Space | Activate focused action. |
ARIA Attributes
- `role="alertdialog"`
- `aria-labelledby`
- `aria-describedby`
Reduced Motion
Overlay and panel transitions respect `prefers-reduced-motion` and reduce to instant state changes.
Affected properties
opacitytransformAPI Reference
AlertDialog
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
open | boolean | - | - | Controlled open state. |
defaultOpen | boolean | - | - | Initial open state for uncontrolled usage. |
onOpenChange | (open: boolean) => void | - | - | Open state change handler. |
variant | "default" | "destructive" | "glass" | "matte" | No | "default" | Variant option from alertDialogActionVariants. |
AlertDialogTrigger
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
asChild | boolean | - | false | Render trigger as child element. |
variant | "default" | "destructive" | "glass" | "matte" | No | "default" | Variant option from alertDialogActionVariants. |
AlertDialogContentProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
variant | PanelVariantProp | No | ambient style (glinr) | Panel look. Omit it for the ambient design style: glinr shell, raised header and footer strips. `plain` is the shadcn border and shadow, `glass` is opt-in and needs a backdrop. Legacy `default` follows the ambient style, `matte` maps to `solid`, `frosted` to `glass`. |
size | "sm" | "md" | "lg" | No | md | Content width and density scale. |
container | HTMLElement | null | No | - | Element to portal into. When set, overlay and content use absolute positioning scoped to the nearest positioned ancestor. |
AlertDialogActionProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
variant | "default" | "destructive" | "glass" | "matte" | No | default | Visual treatment for the confirm action. `default` is the neutral solid button, `destructive` uses the danger tone. |
AlertDialogCancel
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
asChild | boolean | - | false | Render cancel action as child element. |
variant | "default" | "destructive" | "glass" | "matte" | No | "default" | Variant option from alertDialogActionVariants. |
Source
Import directly from the package or browse the source on GitHub. Click any file to view it.
Import
import { AlertDialog } from "@glinui/ui"Source Files
Dependencies
@glinui/uiGenerated API Snapshot
Beta
Generated API Snapshot
BetaAuto-extracted from TypeScript source in packages/ui/src/components/alert-dialog.tsx. This section is in beta and may lag behind hand-curated docs. Regenerate with pnpm --filter @glinui/docs api:generate.
Generated: 2026-10-08T01:41:21.546Z · Full index: /docs/api-metadata
Primary Props Type
AlertDialogActionProps
AlertDialogActionProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
variant | "default" | "destructive" | "glass" | "matte" | No | "default" | Variant option from alertDialogActionVariants. |
AlertDialogContentProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
container | HTMLElement | null | No | - | Element to portal into. When set, overlay and content use absolute positioning scoped to the nearest positioned ancestor. |
size | "sm" | "md" | "lg" | No | "md" | Variant option from alertDialogSizeVariants. |
variant | PanelVariantProp | No | - | Surface look. Omit for the ambient design style (glinr by default). `glass` is opt-in and needs a rich backdrop. |