Toast
Allows you to convey quick messaging notifications to the user. E.g When an action is completed, a success toast notification can be displayed and dismissed by the user or dismissed after a set amount of time has passed. Alternatively, a CTA can be used with the toast to allow the user to proceed with next steps or try again
Example
Default toast
Variants
Complex toast
Anatomy
- Icon (situational): Used as a supporting element for the notification, giving more context to the nature of the notification.
- Title: Name of the toast letting users know what the toast is about.
- Close icon (situational): Used when you are not using time-based toasts. This allows users to manually dismiss the toast
- CTA (situational): Used to allow users to carry out actions immediately upon completion of a task.
Spacing
Within the toast
Ensure that there is a min of 16px spacing within the toast notification and 16px spacing between content and CTA.
Usage guidelines
Best practices:
- Titles should not stretch beyond two lines.
- Avoid technical jargon.
Toasts should be used when:
- You want to present quick snippets of information to users. Such as when users have submitted a form successfully or when a system error occurs.
- Showing non-critical messages that do not require immediate user action and interaction.
Toasts should not be used when:
- Conveying important alerts. E.g If your system is going down for maintenance.
Usability guidelines
Don't stack the notifications
Avoid stacking multiple toasts together as this will cause confusion for users.
If stacking cannot be avoided, ensure that the toasts are of a similar nature. E.g Error messaging.
Make sure they are small and unobtrusive
This is so that content is not blocked and is part of the users natural task flow
Make toasts as brief as possible
Toasts convey quick snippets of information and therefore should not contain more than 2-3 lines of text.
The content should make sense with as little words as possible. E.g Message sent vs Your message has been sent.
Provide sufficient time for users to read and interact with the toast. If the toast disappears automatically, ensure it does not disappear too quickly or consider allowing users to dismiss it on their own with a close button.
Accessibility guidelines
Aria attributes
-
Use
role="alert"
to define a live region and force screen readers to announce the content of the toast. -
Setting
role="alert"
is equivalent to settingaria-live="assertive"
andaria-atomic="true"
.
Focus indicator
- When a toast notification appears, ensure it does not automatically steal focus from the current task. Instead, use ARIA live regions to announce the toast content.
- If interaction is required (e.g., buttons within the toast), provide a mechanism for users to move focus to the toast using the keyboard.
- If a toast notification requires user interaction (like dismissing or performing an action), use focus trapping to keep the keyboard focus within the toast until the interaction is complete.
Toast design tokens
Last updated 02 October 2024