Components/Surfaces/AlertDialog
COMPONENT20.20

AlertDialog

Modal confirmation for destructive actions — a native <dialog> with role="alertdialog", opened via command/commandfor.


INSTALL

1pnpm dlx @sayagodev/mo add dialog

Or import the files from the package (no copy):

1import "@sayagodev/mo/css/dialog.css";2import "@sayagodev/mo/js/base.js";

EXAMPLES

Basic

Are you absolutely sure?

This action cannot be undone. This will permanently delete your account from our servers.

Destructive

Delete chat?

This will permanently delete this chat conversation. View Settings to delete any memories saved during this chat.

With media

Share this project?

Anyone with the link will be able to view and edit this project.

USAGE

1<button command="show-modal" commandfor="ad1">Delete</button>2 3<dialog id="ad1" role="alertdialog" aria-labelledby="ad1-title">4  <form method="dialog">5    <header>6      <h3 id="ad1-title">Are you absolutely sure?</h3>7      <p>This action cannot be undone.</p>8    </header>9    <footer>10      <button type="button" class="ghost" value="cancel" command="close" commandfor="ad1">Cancel</button>11      <button type="submit" value="confirm">Continue</button>12    </footer>13  </form>14</dialog>

API

NAMEKINDDESCRIPTION
role="alertdialog"attributeOn <dialog> — announces interruption semantics to AT
aria-labelledbyattributePoints at the title heading id
commandfor / commandattributeDeclarative open/close (Safari polyfilled); Esc closes natively
method="dialog"attributeButtons close and set returnValue (cancel · delete)
> header > div (media)elementIcon box composed inline: muted or destructive-tinted square

FILES

src/css/dialog.csssrc/js/base.js
Install:mo add dialog

THEMING · PLAYGROUND

This is the exact component from the examples above, wearing a completely different theme. Edit the tokens and --mo-* hooks in the editor — autocomplete knows them all — and the preview obeys in real time. Your CSS always wins.

Tokens & hooks — edit live
Global tokens
--border--card--muted--muted-foreground--radius
Component hooks
--mo-dialog-max-width--mo-dialog-radius

Preview

Delete workspace

This erases every project inside it. There is no undo.

Your CSS

Try it: type --mo- for the component hooks, or edit any value — the preview obeys in real time.