Box Modal

A typical "boxed" modal (JS variant), sizes can be adjusted with modifiers.

Dependencies

This component uses the following to create the full UI.

JS:
Note:

This component *needs* javascript to be enabled and to load correctly to work.

Basic Example

A typical "boxed" modal, using Alpine JS to toggle state between in-active and active. Includes adjusting aria attributes for accessibility.

Box modal sizes

Box modal sizes can be adjusted with a few modifiers.

Body elements

Layout options for the box modal include a bordered header and footer.

Managing overflow

When space is limited i.e on a mobile device, ensure the content is scroll-able within the modal.

Notes:

Add the Alpine.js .noautofocus modifier to the x-trap attribute to stop auto focus on the first element that is focusable. This is handy for situations where there is a button situated at the bottom of the scrollable content.

alpinejs.dev x-trap

Close

Allow the dialog element to be closed with a "X" button.


Useful notes and reading:

Related components:

Useful Links: