AlertDialog
Native confirmation dialog with least-destructive initial focus.
All components · Theme builder · Implementation source
Live preview
Open live alert-dialog preview
Install
netscript ui:add alert-dialogUsage and examples
The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.
import { useState } from 'preact/hooks';
import { AlertDialog } from '@app/components/ui/alert-dialog.tsx';
export function Example() {
const [value, setValue] = useState('standard');
const [open, setOpen] = useState(false);
const [notice, report] = useState('');
return (<><div><AlertDialog triggerLabel="Review deletion" title="Delete order?" description="This action cannot be undone." actionLabel="Delete order" onAction={()=>report("Order deleted")} /></div><p role="status">{notice}</p></>);
}Props
Generated from native deno doc --json --private over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.
| Owner | Prop | Type | Optional | Description |
|---|---|---|---|---|
AlertDialogProps | triggerLabel | string | No | |
AlertDialogProps | title | ComponentChildren | No | |
AlertDialogProps | description | ComponentChildren | No | |
AlertDialogProps | children | ComponentChildren | Yes | |
AlertDialogProps | actionLabel | string | No | |
AlertDialogProps | cancelLabel | string | Yes | |
AlertDialogProps | variant | "default" | "destructive" | Yes | |
AlertDialogProps | size | "sm" | "md" | Yes | |
AlertDialogProps | media | boolean | Yes | |
AlertDialogProps | mediaIcon | ComponentChildren | Yes | |
AlertDialogProps | open | boolean | Yes | |
AlertDialogProps | defaultOpen | boolean | Yes | |
AlertDialogProps | onOpenChange | (open: boolean) => void | Yes | |
AlertDialogProps | onAction | () => void | Yes | |
AlertDialogProps | onCancel | () => void | Yes | |
AlertDialogProps | pending | boolean | Yes | |
AlertDialogProps | disabled | boolean | Yes | |
AlertDialogProps | class | string | Yes |
Keyboard
| Key | Action |
|---|---|
Tab/Shift+Tab | Cycle focus within modal |
Escape | Cancel and restore trigger focus |
Tokens
Semantic contract roles: surface/card, text/fg.
CSS custom properties referenced directly: --ns-border, --ns-border-width, --ns-card, --ns-card-padding, --ns-control-gap, --ns-destructive-hover, --ns-destructive-subtle, --ns-destructive-text, --ns-fg, --ns-leading-small, --ns-muted, --ns-muted-fg, --ns-overlay, --ns-radius-card, --ns-radius-control, --ns-shadow-md, --ns-space-10, --ns-space-16, --ns-space-2, --ns-space-4, --ns-space-8, --ns-text-small, --ns-text-strong, --ns-weight-strong.
Contract and compatibility
Accessibility pattern: WAI-ARIA guidance
- Context-only Root composes public native Dialog. Native backdrop requires no extra DOM; no close icon or outside-click dismissal.
- Cancel receives initial focus. Native Escape requests cancel; pending disables only the action. App callbacks and asynchronous work remain caller-owned.
- Action includes Button label/spinner parts. Canonical destructive fill/foreground roles are preserved; the scoped hover uses destructive/hover rather than the generic legacy raw red ramp. Token values remain owned by #2450.
- Open/closed runtime hooks remain on trigger/content; browser-forced dismissal remains native behavior.
Design contract values marked planned are not implementation props. The props above describe what ships today.