Dialog
Usage
Include CSS
Import Tailwind and one full A3S UI style bundle.
Or import only the base CSS, Dialog component CSS, and one style pack.
Using CDN or bundler imports? See the Installation page.
Add your dialog HTML
A3S UI uses the native <dialog> element and showModal(). This differs from shadcn/ui's portalled Base UI implementation, but preserves native modality, focus handling, and inert page content without component JavaScript.
HTML structure
<button type="button" onclick="dialog.showModal()">Optional- Trigger button. A3S UI intentionally uses the native
HTMLDialogElement.showModal()method. <dialog class="dialog" id="{ DIALOG_ID }">Native modal dialog. Add
aria-labelledby="{ TITLE_ID }"andaria-describedby="{ DESCRIPTION_ID }"when title and description are present. Add width utilities to the inner<div>when a dialog needs a custom size. The macro also adds backdrop-click close handling.<div>Dialog content surface.
<header>OptionalDialog header.
<h2 id="{ TITLE_ID }">- Dialog title. Reference it from
aria-labelledby. <p id="{ DESCRIPTION_ID }">Optional- Dialog description. Reference it from
aria-describedby.
<section>Optional- Dialog body/content area. Add overflow utilities when the body should scroll.
<footer>Optional- Action area. It stacks actions on small screens and aligns them to the end on larger screens.
<button type="button" onclick="this.closest('dialog').close()">Optional- Close button. You can also wrap a button in
<form method="dialog">.
Examples
Custom close button
No close button
Sticky footer
Scrollable content
RTL
Dialog positioning and close button placement use logical properties. Set dir="rtl" on the dialog or a parent element.