Dialog
A modal window that interrupts the user to require action or display information.
The dialog component displays content in a focused modal overlay, forcing the user to interact with it before returning to the main page. It follows the WAI-ARIA Dialog Pattern(Opens in a new tab)
.
Edit Profile
Make changes to your profile. Click save when you're done.
Go/HTML template
Reference
ui/dialog
- trigger
"trigger" "Open Dialog"— (string, optional)- The label text for the trigger button. Default:
"Open Dialog". - title
"title" "Edit Profile"— (string, optional)- The dialog title rendered in a
<h2>header. When set,aria-labelledbyis automatically linked. - description
"description" "Make changes..."— (string, optional)- Supplementary description below the title. When set,
aria-describedbyis automatically linked. - open
"open" true— (bool, optional)- Initial open state. Default:
false.
Installation
The Dialog component is disabled by default to save resources.
Uncomment the imports in the following files:
/assets/js/main.js
/assets/css/main.css
Prerequisites
The Get Started: Manual Installation
steps must be completed!
JavaScript
Create the Alpine module:
Alpine Js
/assets/js/modules/dialog.js
Import and register it in main.js:
Alpine Js
/assets/js/main.js
Hugo Partial
Create the partial file:
Go/HTML template
layouts/_partials/ui/dialog.html
Hugo Shortcode
Go/HTML template
layouts/_shortcodes/ui/dialog.html
CSS Styling
Create the CSS component:
Tailwind CSS
assets/css/components/_dialog.css
Import it in your main Tailwind file:
Tailwind CSS
assets/main.css
Usage
Using Partials (Templates)
HTML
layouts/home.html
Using Shortcodes (Markdown)
Markdown
content/example.md
Accessibility
The component follows the WAI-ARIA Dialog Pattern(Opens in a new tab) :
- Focus Trap: Uses
x-trap.noscrollto confine keyboard focus within the dialog when open. - Modal State:
role="dialog"andaria-modal="true"inform assistive technology. - Labelled & Described:
aria-labelledbylinks to the title element;aria-describedbylinks to the description when provided. - Dismissible: Pressing
Escapecloses the dialog. Clicking the backdrop overlay also closes it. - Scroll Lock:
x-trap.noscrollprevents background scrolling while the dialog is open. - Close Button: A dedicated close button with
aria-label="Close"is provided.