Alert
Alerts provide short, timely, and relevant information for your users.
Example
Default alert
With link
Additional content
Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
Dismissable
Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.
Anatomy
- Icon (situational): Serves to give more context to the alert.
- Text: Serves to tell users what the alert is about.
- Close icon (situational): Can be used as a close button to allow users to dismiss the alert.
- Container: Serves to house the content of the alert. Width and height will vary depending on the amount of content within.
Spacing
Within the alert
Ensure that there is a min of 16px vertical spacing and 24px horizontal spacing within
the alert and 16px spacing between icon and text. Base height 64px.
Usage guidelines
Best practices:
- Alert banner should come back into view at the next possible occasion if the user dismisses it without resolving it.
- Be clear and concise. If possible, include an in-line action for a user to take so that they can address the issue explained in the message.
Alerts should be used when:
- You need system status messaging - The alert may be in the form of a notification that keeps users informed of the status of a system. This may or may not require the user to take action and/or respond. Some examples of this can be in the form of errors, warnings or generic updates for the users.
Alerts should not be used when:
- You need to display validation errors, these should be displayed on the component that the user is on.
- There are multiple alerts on a single page. E.g A notification alert and a error/warning alert. Use the one that is most important to the user.
Usability guidelines
Do not use multiple notifications on a page
This may overwhelm or annoy users and may result in them ignoring the notification altogether.
Dismissable alerts
Avoid triggering interaction with a badge as they may be confused as small buttons.
Proper context
Do not use alerts that are not related to a user's goal.
Behaviour
Users should be able to close a dismissible notification by clicking the close x. Alerts can include high and low contrast to differentiate critical messaging. low contrast will be less visually disruptive for users.
Accessibility guidelines
Aria attributes
-
The widget has a
role="alert"
.
Keyboard accessibility
- The only interactive elements are HTML button and hyperlink elements, and all the keyboard functionality is provided by browsers.
Focus indicator
- Ensure that focus is moved to the alert when it appears to ensure screen reader users are aware of it.
- Ensure interactive elements within the alert (like a close button) are accessible via the keyboard.
Alert design tokens
Last updated 02 October 2024