Components / Library Version 5.14.0
Snackbar
The snackbar component renders a notification at the bottom of the screen to provide feedback to the user. In addition to a message, the notification can also include a link.
Properties
* Required property
string
id
, message
, and link
(optional). If the link
should open in a new window include newWindow: true
. Pass an empty array when no notifications should be rendered or when you
want to clear the notifications.
Usage in HTML
Edit the code below to see changes reflected in the example above.
Javascript Sample
Example code for functionality.
Usage in Elm
Code generated from HTML.
- the user tabs out of the snackbar
- the user clicks the close button
- after 6 seconds (except if the snackbar has a link, in which case it should only be dismissed by user action)
The component renders an aria live region. The live region updates without a page reload. Changes to it (in this case, new notifications) are announced by screenreaders.
Screen Readers
Snackbar
- does not gain focus.
- disappears automatically after 6 seconds.
Snackbar with link
- When the snackbar appears, the link in the snackbar gains focus.
- The timer is disabled.
- When the user tabs out of the snackbar or actively dismisses it, focus returns to where they were before the snackbar appeared.
Keyboard Support
Snackbar
None.
Snackbar with link
Key | Function |
---|---|
Tab |
|
Shift + Tab |
|
Enter |
|
The snackbar component renders the notifications passed to it via the notifications
property. When a user deletes a notification or when the snackbar times out, the component emits an event which should be used to update the notifications list.
The snackbar emits an event when the link is clicked, which should be used to redirect to the appropriate resource.