Components
Dialog
There are two types of dialogs: modal and non-modal. When a modal dialog is open, the rest of the page is dimmed, and users can only interact with content inside the dialog. A non-modal dialog allows users to continue using the page, even while the dialog is open.
Things you need to check yourself
Non-modal dialogs
When using non-modal dialogs, you must ensure that elements receiving focus through keyboard navigation do not end up behind the dialog and become hidden. This applies at all screen sizes. On small screens the risk is greater, because the dialog takes up a larger part of the available space.
See criteria 2.4.11 (w3.org) (AA) and 2.4.12 (w3.org) (AAA).
For non-modal dialogs, this means you must:
- Ensure that focusable elements are never completely covered by the dialog when users navigate the page using the Tab key.
- Ensure that the focus order is logical and that focus is always visible, so users navigating with a keyboard or screen reader can understand where focus is located.
Designsystemet takes care of
- Logic for moving focus when the modal opens
- Logic for returning focus to the triggering button when the dialog closes
- Correct roles
- Focus trap in modal dialogs to ensure focus loops until the modal closes
- Automatic accessible name on the dialog element when a heading is present
aria-haspopup="dialog"is automatically added to interactive elements that open a dialog