Dialog Component

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"].

Notes

Open methods

:target anchor

Open standard dialog

JS show() — no backdrop

JS showModal() — with backdrop

Basic dialogs

Standard dialog

Header, body, footer structure.

Open

Simple dialog

Body only, no header/footer.

Open

Long content

Scrollable content.

Open

Dialog Title

Standard dialog with full header, body, and footer.

Close via top-right X, footer button, or ESC key.

Close

Simple dialog with body only.

Close

Long Content

Demonstrating scrollable content inside a dialog.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.

Close

JS show() Dialog

Opened via dialog.show() — no backdrop.

Close

showModal() Dialog

Opened via dialog.showModal() — with backdrop overlay.

Close

Class dialog component

Pure CSS dialog built with .dialog + .dialog-wrapper structure. Toggled by adding / removing the .dialog-open class.

Notes

Available child nodes of .dialog:

Basic usage

Complete structure with tools, title, body, footer and note.

Dialog Title

Full dialog structure with header, body, footer and note.

This is a note

Positions

9 positions are supported, the default is center. dialog-center === dialog-center-center.

center (default)

Absolutely centered dialog (default).

top-start

Dialog at the top-start corner.

top-center

Dialog at the top-center.

top-end

Dialog at the top-end corner.

center-start

Dialog at the center-start corner.

center-center

Dialog at the center-center.

center-end

Dialog at the center-end corner.

bottom-start

Dialog at the bottom-start corner.

bottom-center

Dialog at the bottom-center.

bottom-end

Dialog at the bottom-end corner.

Width

dialog-100

Width = 100 spacing units (100 * 4px).

dialog-scale

Width = --default-width-input.

dialog-scale-2

Width = 2 × --default-width-input.

dialog-full

Full horizontal width minus side gaps.

Special size

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

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.

Special types

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.

Tools outside

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.

Tools outside

Tools bar is placed outside the wrapper on the side.

Dialog inside a container (Absolute)

.dialog-absolute confines the dialog inside a relative container. Close the dialog, then reopen it from the button inside the box.

Absolute dialog

Dialog confined inside the relative container above.

Full-size media

dialog-media displays a single media item (image, video or iframe). The .dialog-body padding becomes 0 so the media fills the dialog.

A picture
A note

Custom open/close animations

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.

Scale dialog

Enter + exit are both applied: animate-scale-in / animate-scale-out.

Fly dialog

Enter + exit are both applied: animate-fly-in-start / animate-fly-out-start.

Footer with complete actions

Full .actions bar with start / center / end groups inside .dialog-footer.

Actions footer

Full actions bar with start / center / end groups.

Footer with .btns .btns-flush

Use .btns.btns-flush inside .dialog-footer — the group fills the footer edge-to-edge (no padding).

Btns flush footer

Footer using a flush button group.

Simplified structure

.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.

No tools

Dialog without .dialog-tools.

Dialog without .dialog-backdrop — surrounding content stays interactive.