{% extends "base.html" %} {% import "components/macros.html" as ui %} {% block title %}Dialog Modals - Design System Wiki{% endblock %} {% block content %}
{% include "components/sidebar.html" %}
Overlays

Dialog Modals

Overlay window popups centering inside the viewport with scale animations, hardware blur filters, and document-level listeners for escape-key/backdrop dismissals.

Modal Showcase & Integration

How the Global Modal JS Works

The global script components.js runs automatically on page load and monitors specific attributes and classes. Here is what makes the modal operational:

Selector / Class Type Behavior & Purpose
[data-modal-target] Attribute Applied to buttons or triggers. The value must match the ID of the modal dialog (e.g., data-modal-target="my-modal"). Clicking it triggers openModal("my-modal").
.modal-dialog Class The outer wrapper container. Starts with the class hidden. The JS removes/adds hidden to show/hide the popup.
.modal-content Class The inner dialog panel card. The JS looks for this class to toggle transitions (adds scale-100 opacity-100 on show; resets to scale-95 opacity-0 on hide).
.modal-backdrop Class The dark blur overlay. The JS toggles its opacity and registers clicks on it to automatically close the modal.
.modal-close Class Applied to any close button (e.g., "Cancel", "Confirm", or an "X" icon). Clicking any element containing this class triggers modal closure.
💡 What is customizable?

You can customize the styling, colors, layout, and sizing of the .modal-content card freely. You must preserve the classes listed above so the Javascript code can target them and apply animations correctly.

Confirmation Actions (e.g., Deletes)

To prevent accidental actions, wrap destructive or state-changing actions (such as deletions) in a confirmation dialog modal. Since modals are populated inside the DOM structure, you can either wrap the action inside a standard HTML form or use HTMX for AJAX deletions.

Demo Project Entity:
Important Draft.docx {{ ui::modal_trigger(target_id="wiki-confirm-delete-modal", label="Delete Draft", variant="destructive", extra_class="!px-2.5 !py-1 text-[10px]") }}
{{ ui::modal_open(id="wiki-demo-modal", title="Wiki Sandbox Modal") }}

This modal is animated and handled globally by components.js. Pressing escape or clicking outside closes it instantly.

{{ ui::modal_close(close_label="Dismiss Modal") }} {{ ui::modal_open(id="wiki-confirm-delete-modal", title="Confirm Deletion") }}

Are you sure you want to permanently delete "Important Draft.docx"? This action cannot be undone.

{{ ui::modal_close_only() }} {% endblock %}