Toasts provide a temporary or dismissable notification positioned in the corner of the application window. Honeycomb provides all style and positional classes but triggering toasts and handling close or delays are currently up to you.
Default toast
Create a default toast by adding .hc-toast to a parent element that contains at least a child content wrapper with class .hc-toast-content.
Accessibility note
The .hc-toast element must have an appropriate role attribute of either status, alert, or log. See the section on accessibility below for more details.
Icon and buttons
Add an icon as the first child element inside of the .hc-toast container. It will always vertically center and be the left-most element.
If adding a CTA button alongside a message, wrap the message in .hc-toast-message first. Then create a primary Button and place it at the end of the .hc-toast-content wrapper.
You can also add a close button by wrapping an icon button inside of an element with class .hc-toast-close as the final child element inside the toast.
If all three items are present there will be three children within the .hc-toast.
Position
Position the toast to the default top-right by adding .hc-toast--top-right to the toast element. Other positions available include .hc-toast--bottom-right, .hc-toast--bottom-left, and .hc-toast--top-left.
These position classes add position: fixed; and an appopriate offset so that they align themselves to the viewport itself. Note that if you inspect these examples here, however, they are absolutely positioned so that they sit inside the example boxes.
Muiltiple toasts
If you need to stack more than one toast, or you just want to leave open the option of stacking more than one, wrap any and all toasts inside of an .hc-toast-wrapper element instead.
Apply position classes to this wrapper element, not the .hc-toast themselves.
Product toasts
Create a branded toast either directly with a class name or through the brand theme that you’ve applied.
The branded theme is preferred and you only need to add .hc-is--brand to the toast element itself, after applying a theme to the <body> element.
Alternatively, you can directly create a specific branded toast by adding the classes .hc-toast--attend, .hc-toast--boost, .hc-toast--connect, and .hc-toast--forms to style the toast in the branded product colors respectively. This will override any theme.
Important Note
Previously the theme was applied with the component-specific class, .hc-toast--brand. This has been replaced as of v0.3.0 to standardize brand variations with .hc-is--brand.
Semantic toasts
Success, info, warning, and danger variants are all available with the classes .hc-toast--success, .hc-toast--info, .hc-toast--warning, and .hc-toast--danger, respectively.
Note that the CTA button should have .hc-button--primary and that we have a slight style variation to this button.
Accessibility note
Note that the .hc-toast--success and .hc-toast--warning semantic states changed the role value to alert. Read more about this below.
Accessibility
WCAG 4.1.3 requires an appropriate role value attached to the .hc-toast element. These values can be status, alert, or log depending on the context.
In general, use status unless either of these two conditions are met:
If the message is a suggested action to take or an error warning, use alert instead
If the message conveys info on the progress of a process, use log instead.
More information
The role="status" attribute is appropriate in all cases where the Toast tells the user of some sucess or result of an action, as well as the state of the application—which is nearly all use cases for a Toast.
The only cases where alert is recommended is when you’re using .hc-toast--danger or .hc-toast--warning because of some negative outcome.
log should rarely if ever be used, as progress is more appropriately conveyed via the Progress component, though the .hc-toast--info semantic state would be appropriate for log-level messages if it’s conveying “sequential information updates.”
This toast was triggered and is positioned relative to the document body.