Introduction
Present actionable content to visitors with dismissable modal dialog overlays.
Modals have keyboard support for focusable elements. Use the Tab and Shift + Tab keys without leaving the model by accident. Using the Esc key closes the model.
When a modal closes, keyboard user return to the last active element in the document.
Include role="dialog" on the modal element.
Provide an accessible name with aria-describedby, referring to the modal title element.
Default Behavior
Use the button below to launch the modal component with default behavior. Modals center horizontally and vertically. Content within the .modal__content__body
selector scrolls (vertically) when its content's height exceeds the height of the viewport.
Line # | Details |
---|---|
3-7 | A button with the The |
11 | The The The |
13-15 | The It centers the modal and holds the modal's header, body, and footer selectors. The The The The The aria-labelledby attribute equals its associated header's |
17-24 | The It holds the modal's header and close icon button. The The |
26-30 | The It holds the modal's main content. |
32-41 | The It selector holds the modal's actionable buttons and links. The |
Scroll Entire Modal
If you wish for the entire modal to scroll, add the .modal--scroll-all
modifier class to the .modal
selector (Figure, 2, line 1).
Close Outside
With the data-modal-close-outside="true"
attribute preset, the modal closes when the user clicks outside of the modal content (Figure 3, line 1).