Modal
A modal disables page content and focuses the user’s attention on a single task or message.
This component requires the following JavaScript plugin:
Examples
Default
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024pxAre you sure you want to continue?
You have unsaved changes that will be lost.
Large
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024pxAre you sure you want to continue?
You have unsaved changes that will be lost.
Forced Action
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024pxYour session will end soon.
You've been inactive for too long. Please choose to stay signed in or sign out. Otherwise, you’ll be signed out automatically in 5 minutes.
Component API
Root
-
x-modal
Custom Alpine directive that marks the Modal Root.
Trigger
-
x-modal:trigger
Custom Alpine directive that marks the Modal Trigger.
Dialog
-
x-modal:dialog
Custom Alpine directive that marks the Modal Dialog.
-
tabindex
Type:
number
Value:-1
Prevents users from tabbing to this element.
Automatically handled with JavaScript.
-
aria-labelledby
Type:
string
Accessibility attribute that links the Modal Dialog to the Modal Title via
id
.Automatically handled with JavaScript.
-
aria-describedby
Type:
string
Accessibility attribute that links the Modal Dialog to the Modal Description via
id
.Automatically handled with JavaScript.
-
aria-modal
Value:
true
Accessibility attribute that indicates that this element is a modal when displayed.
Automatically handled with JavaScript.
-
role
Value:
'combobox'
Attribute that allows assistive technology identify that the content contained in the modal is grouped and seperate from the reast of the page content.
Automatically handled with JavaScript.
Content
-
x-modal:content
Custom Alpine directive that marks the Modal Content.
Title
-
x-modal:title
Custom Alpine directive that marks the Modal Title.
-
id
Type:
string
Used to link the Modal Title to the Modal Dialog via
aria-labelledby
.Automatically handled with JavaScript.
Description
-
x-modal:description
Custom Alpine directive that marks the Modal Title.
-
id
Type:
string
Used to link the Modal Description to the Modal Dialog via
aria-describedby
.Automatically handled with JavaScript.
Close Button
-
x-modal:close-button
Custom Alpine directive that marks the Modal Close Button.
Backdrop
-
x-modal:backdrop
Custom Alpine directive that marks the Modal Backdrop.
This element is automatically appended to the document body
, ensuring that this element always properly overlays page contents when opened.
Keyboard Interactions
-
Escape
When the Modal Dialog is open, closes the Modal Dialog and moves focus to the Modal Trigger.