{% extends "base.html" %} {% import "components/macros.html" as ui %} {% block title %}Dialog Modals - Design System Wiki{% endblock %} {% block content %}
Overlay window popups centering inside the viewport with scale animations, hardware blur filters, and document-level listeners for escape-key/backdrop dismissals.
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. |
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.
This modal is animated and handled globally by components.js. Pressing escape or clicking outside closes it instantly.