Alert Dialog
A modal dialog that interrupts the user with important content and expects a response.
Usage
Include CSS
Import Tailwind and one full A3S UI style bundle.
Or import only the base CSS, Alert Dialog component CSS, and one style pack.
Alert Dialog uses the Dialog component CSS.
Using CDN or bundler imports? See the Installation page.
Add your alert dialog HTML
Alert Dialog uses a native <dialog class="alert-dialog"> element. Omit the close button and backdrop-click handler when the user must choose an explicit action.
HTML structure
<button type="button" onclick="dialog.showModal()">Optional- Trigger button. A3S UI uses the native
HTMLDialogElement.showModal()method. <dialog class="alert-dialog" id="{ DIALOG_ID }">Native modal dialog. Add
aria-labelledbyandaria-describedbywhen title and description are present. Usedata-size="sm"for the compact upstream size.<div>Dialog content surface.
<header>Alert dialog header.
<figure>Optional- Media area for an icon or image.
<h2 id="{ TITLE_ID }">- Alert dialog title. Reference it from
aria-labelledby. <p id="{ DESCRIPTION_ID }">Optional- Alert dialog description. Reference it from
aria-describedby.
<footer>- Action area. Include a cancel action and the primary action.
Examples
Basic
A basic alert dialog with a title, description, and cancel and continue buttons.
Media
Use a <figure> in the header to add a media element such as an icon or image to the alert dialog.
Destructive
Use a destructive action button when the alert dialog confirms a destructive operation.
Small
Use data-size="sm" for a compact alert dialog. The small size keeps media, title, and description stacked and centers the action buttons in a two-column footer.
RTL
Alert Dialog supports document direction. Set dir="rtl" on the dialog or a parent element.