Usage
role="alertdialog", a required title and description, and a cancel action that holds focus on open. For a task that needs a form or a choice, use Dialog.
@prepared911/ui/alert-dialog from its subpath. Load @prepared911/ui/styles.css once at the document root.
AlertDialog owns open state. Pass open and onOpenChange to control it, or defaultOpen to start open.AlertDialogTrigger wraps one Button or Link and opens the dialog. Focus returns to it on close.AlertDialogContent is the modal surface. title (an h2) names it and description describes it; both are required and always visible. size is Medium (default, 512px) or Small (384px). The description fills the content width and wraps at the edge, as ui-core's does.AlertDialogFooter holds the actions, aligned to the inline end. The cancel goes first and the action last. Both Buttons render at Button's default ButtonSize.Large (32px), which matches the rendered ui-core modal footer (pr-button--large).AlertDialogCancel wraps one Button and closes the dialog without applying the action. It is where focus lands on open.AlertDialogAction wraps one Button. The Button's own onClick performs the action, then the dialog closes.details.cancel() and open the AlertDialog; "Keep editing" closes only the alert dialog, and the action closes both.
onOpenChange(open, details) runs once for each request: trigger-press, close-press (the cancel or the action), and close-request (Escape or the platform back gesture). For a close-press, details.source is the pressed Button. Call details.cancel() on a cancelable request to keep the dialog open, for example while an async action runs: control open, start the work in the action's onClick, and veto the close-press until it settles.
On open, focus moves to the cancel action, so pressing Enter or Space never confirms by accident. For a confirmation that is not destructive, pass initialFocus with a ref to the action. If the dialog has no cancel action, focus goes to the first focusable element. On close, focus returns to the trigger; pass finalFocus to send it elsewhere.
The shell provides what an alert dialog needs from the page, once: its entry imports @prepared911/ui/styles.css, it sets data-theme on the document element, and it renders DesignSystemEnvironment for the locale and time zone (see remote composition). An AlertDialog needs no provider, portal root, or z-index: it is a native <dialog> opened with showModal(), so it paints in the top layer above the shell's chrome, a slot's overflow, transform, or z-index cannot clip or cover it, and the page behind it does not scroll. It renders in place and takes the theme of the nearest data-theme region around its trigger.
AlertDialogTrigger clones its child, so a RemoteComponent mount cannot be the trigger. A remote that asks for an answer renders the whole AlertDialog, trigger included, imported from @prepared911/ui/alert-dialog as above, and imports no @prepared911/ui stylesheet. When the shell owns the trigger, the shell renders the AlertDialog too, and a remote can fill a Dialog's content slot instead. Focus starts on the cancel, Tab stays in the dialog, and Escape returns focus to the trigger inside the remote.