unscripted/ui

Alert Dialog

A confirmation that interrupts on purpose — the same native <dialog> as the modal, with light dismiss switched off and alertdialog semantics. The whole diff is a few attributes.

dialogexit animations

Dialog vs Alert Dialog

An alert dialog interrupts to demand a decision, usually a destructive one, so a stray click on the backdrop must not dismiss it. Same element as Dialog but with a different dismissal policy.

How it works

  • closedby="closerequest" prevents the user from dismissing the dialog by clicking on the backdrop. This is also the default behavior in browsers without closedby support, so the dismissal policy is identical everywhere <dialog> exists.
  • role="alertdialog" tells screen readers this is an interruption that needs a response, and with aria-describedby pointing at the consequence text, the question is announced in full when the dialog opens.
  • Everything else — top layer, focus trap, inert background, the overscroll-none scroll-lock, the declarative commandfor trigger, the entry/exit animation — is the Dialog verbatim.

Accessibility

Focus lands on the first focusable element when the dialog opens — here that’s Cancel, because it comes first in the markup. That’s the right default for a destructive confirm: Enter pressed out of reflex backs out instead of deleting. Keep the safe action first in source order.

Browser support

Minimum stable version per engine, resolved at build time from MDN's browser-compat-data; Baseline status from the official web-features dataset. Everything degrades gracefully — the “when missing” column is the actual behavior, not a broken page.

FeatureChromeEdgeFirefoxSafariWhen missing
<dialog> elementBaseline · widely available37799815.4Baseline, widely available. Modal behavior, focus handling and Esc-to-close are native.
Invoker commands (commandfor / command)Baseline 2025 · newly available13513514426.2Buttons with commandfor do nothing. Until Baseline reaches your audience, open the dialog with a 3-line shim or from your framework.
Entry/exit animations (allow-discrete + @starting-style)Baseline 2024 · newly available11711712917.5Elements appear and disappear instantly. Nothing breaks — you just lose the animation.

† @supports cannot test at-rules, so the badge checks transition-behavior: allow-discrete, which co-shipped with @starting-style in every engine.

‡ HTML feature — @supports can only test CSS, and we ship no JS to detect it, so it gets no live badge.