Native <dialog> component. Supports :target (anchor), show() and
showModal() open methods. Structure: dialog > [data-role="header"] > [data-role="title"] +
[data-role="tools"] + [data-role="body"] + [data-role="footer"].
<dialog> element — accessible and semantic.:target (anchor link), dialog.show() (no backdrop),
dialog.showModal() (with backdrop).
data-role="header" / data-role="title",
data-role="tools", data-role="body", data-role="footer".
<a href="#dialogId"> to open and <a href="##"> to close.Pure CSS dialog built with .dialog + .dialog-wrapper structure. Toggled by adding /
removing the .dialog-open class.
.dialog (overlay) → .dialog-wrapper (card surface)..dialog-open and .dialog-close are mutually exclusive: add .dialog-open
to show, remove it and add .dialog-close to hide..dialog-backdrop is optional — without it the dialog clicks through.Available child nodes of .dialog:
.dialog-wrapper — content wrapper (card surface, required).dialog-backdrop — backdrop layer (optional; without it the dialog clicks through).dialog-tools — tools bar, absolutely positioned top-end (optional).dialog-header — header container (optional; auto-hidden when empty)
.dialog-title — title, child of header (optional, ellipsis truncation).dialog-body — scrollable main area (required)
.dialog-content — content container, child of body (inherits border radius).dialog-footer — bottom action area (optional)
.actions — action bar with start / center / end groups.btns.btns-flush — flush edge-to-edge button group.dialog-note — note text area at the bottom (optional)Complete structure with tools, title, body, footer and note.
9 positions are supported, the default is center. dialog-center ===
dialog-center-center.
Absolutely centered dialog (default).
Dialog at the top-start corner.
Dialog at the top-center.
Dialog at the top-end corner.
Dialog at the center-start corner.
Dialog at the center-center.
Dialog at the center-end corner.
Dialog at the bottom-start corner.
Dialog at the bottom-center.
Dialog at the bottom-end corner.
dialog-* — any arbitrary width.dialog-scale-* — proportional sizes based on --default-width-input;
dialog-scale equals the default width of <input type="text">.dialog-full — full width (keeping safe side gaps).Width = 100 spacing units (100 * 4px).
Width = --default-width-input.
Width = 2 × --default-width-input.
Full horizontal width minus side gaps.
dialog-fullscreen is a special size: absolutely centered and fills the whole screen (keeping safe gaps
on all sides). It is mutually exclusive with the position and width utilities.
Fullscreen-centered dialog, body flexes to fill and scrolls.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.
Confirm / alert / prompt — transparent backdrop, not click-through, simulating native JS dialogs.
Native confirm style: transparent backdrop, not click-through.
Native alert style: transparent backdrop, not click-through.
Native prompt style: transparent backdrop, not click-through.
When the content fills the dialog, you may want to move the tools outside the wrapper.
.dialog-tools-outside places the tools bar outside / beside the wrapper.
.dialog-absolute confines the dialog inside a relative container. Close the dialog, then reopen it
from the button inside the box.
Dialog confined inside the relative container above.
dialog-media displays a single media item (image, video or iframe). The .dialog-body padding becomes 0 so the media fills the dialog.
Apply both enter and exit animation utilities to .dialog-wrapper via Tailwind variants. The enter
animation is scoped to .dialog-open, while the exit animation is scoped to .dialog-close —
since the two classes are mutually exclusive, the correct animation plays automatically.
[:where(.dialog.dialog-open)_&]:animate-*-in — enter ·
[:where(.dialog.dialog-close)_&]:animate-*-out — exit
See demo-animation.html for more available animations.
Enter + exit are both applied: animate-scale-in / animate-scale-out.
Enter + exit are both applied: animate-fly-in-start / animate-fly-out-start.
Full .actions bar with start / center / end groups inside .dialog-footer.
Full actions bar with start / center / end groups.
Use .btns.btns-flush inside .dialog-footer — the group fills the footer edge-to-edge (no
padding).
Footer using a flush button group.
.dialog-title, .dialog-header, .dialog-tools, .dialog-footer,
.dialog-backdrop and .dialog-note are all optional.
Dialog without .dialog-title — the empty header collapses.
Dialog without .dialog-header.
Dialog without .dialog-tools.
Dialog without .dialog-backdrop — surrounding content stays interactive.