Components
Dialog
- Overview
- Usage
Overview
Principles
Dialogs work best when they’re expected and initiated by a user’s action, like clicking a button or link.
When dialogs frequently appear for non-critical information, users may instinctively close them without reading the content. This increases the chance users dismiss important dialogs that appear later without giving them any thought.
When people enter a dialog task, they switch away from their previous context, so it is recommended to set the new context with a heading. Headings are crucial for screen reader users who cannot see the dialog appear on top of the previous context. The dialog’s heading should match or contain similar words to the button label users tapped to open it.
Dialogs shouldn’t contain large amounts of content or complex data. Keep them simple and focused. If the content is too long, it probably should have its own page.
Avoid showing multiple dialogs at the same time.
Size
TDS has 4 standard widths for dialogs. Custom width may be defined if the content requires it.
- Small: 480px
- Medium: 640px
- Large: 800px
- Fluid: 90% width
On mobile, the width of a dialog is defined as 100% with 1-2rem margin on the left and right side.
Closing
By default, dialogs can be closed by:
- Primary button to submit their changes, e.g., “Save” or “Done”
- “Cancel” button in the footer
- ”X” icon on top right corner
- Pressing ESC on the keyboard
- Tapping the scrim behind the dialog
If the user is required to take action (for example, after some period of inactivity, continue using the site or log out) in order to dismiss the dialog, the “X” icon should not be visible and pressing ESC or tapping the scrim should not close the dialog.
Scrolling
Try to keep the content of the dialog simple and concise. In case it’s not at all possible, the scroll behavior can be set so that scrolling happens inside the dialog body or the whole dialog scrolls within the viewport.
Destructive actions
Dialogs can be used to confirm destructive actions, for example deleting something permanently. In this case a danger button should be used for the destructive action.
Usage guidelines
Multiple dialogs
Avoid showing multiple dialogs at the same time.
Use a title
A dialog should always have a title. If a dialog is opened by a user, the title should match or contain similar words to the button label they tapped to open it.
Avoid overly complex content
Dialogs shouldn’t contain large amounts of content or complex data. Keep them simple and focused. If the content is too long, it probably should have its own page.