Skip to main content
NetScriptdocs Search docs ⌘K v0.0.9
Browse documentation

AlertDialog

Native confirmation dialog with least-destructive initial focus.

All components · Theme builder · Implementation source

Live preview

Open live alert-dialog preview

Install

Shell
netscript ui:add alert-dialog

Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

TypeScript
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.

OwnerPropTypeOptionalDescription
AlertDialogPropstriggerLabelstringNo
AlertDialogPropstitleComponentChildrenNo
AlertDialogPropsdescriptionComponentChildrenNo
AlertDialogPropschildrenComponentChildrenYes
AlertDialogPropsactionLabelstringNo
AlertDialogPropscancelLabelstringYes
AlertDialogPropsvariant"default" | "destructive"Yes
AlertDialogPropssize"sm" | "md"Yes
AlertDialogPropsmediabooleanYes
AlertDialogPropsmediaIconComponentChildrenYes
AlertDialogPropsopenbooleanYes
AlertDialogPropsdefaultOpenbooleanYes
AlertDialogPropsonOpenChange(open: boolean) => voidYes
AlertDialogPropsonAction() => voidYes
AlertDialogPropsonCancel() => voidYes
AlertDialogPropspendingbooleanYes
AlertDialogPropsdisabledbooleanYes
AlertDialogPropsclassstringYes

Keyboard

KeyAction
Tab/Shift+TabCycle focus within modal
EscapeCancel 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.

Search all documentation

Type a term to search the documentation.