Sorry, but you either have no stories or none are selected somehow.
If the problem persists, check the browser console, or the terminal you've run Storybook from.
The component failed to render properly, likely due to a configuration issue in Storybook. Here are some common causes and how you can address them:
This is a pre-release version and is not production ready. For new and ongoing projects, please refer to the latest Design System version.
Push notifications to your visitors with a .toast
element, a lightweight and easily
customizable alert message.
Toasts are lightweight notifications designed to mimic the push notifications that have been popularized by mobile and desktop operating systems. They are intended to be small interruptions to your visitors or users, and therefore should contain minimal, to-the-point, non-interactive content.
preview-5491--swisspost-design-system-next.netlify.app/?path=/docs/825b65c9-7eaf-4e0a-9e20-5f5ed406726d--docs&story=Default#825b65c9-7eaf-4e0a-9e20-5f5ed406726d--default
/?path=/story/825b65c9-7eaf-4e0a-9e20-5f5ed406726d--default&full=true
<div aria-atomic="true" class="toast toast-neutral toast-dismissible" role="status" aria-live="polite" > <button class="toast-close-button" aria-label="close"></button> <div class="toast-title">Title</div> <div class="toast-message"> This is a sample toast message to demonstrate the component functionality. </div> </div>
Make sure the @swisspost/design-system-styles
package is already present in your project or follow the installation guidelines.
To import all Design System styles:
@use '@swisspost/design-system-styles/post-compact.scss';
To import only the styles required for this component:
@use '@swisspost/design-system-styles/basics.scss'; @use '@swisspost/design-system-styles/components/toast.scss';
The following examples show the different characteristics of the component. These can differ in the type of visualization, the HTML structure, as well as when, how and why they are displayed.
preview-5491--swisspost-design-system-next.netlify.app/?path=/docs/825b65c9-7eaf-4e0a-9e20-5f5ed406726d--docs&story=Auto Close#825b65c9-7eaf-4e0a-9e20-5f5ed406726d--auto-close
/?path=/story/825b65c9-7eaf-4e0a-9e20-5f5ed406726d--auto-close&full=true
Toasts should be closed automatically after a while, because they usually overlay the regular content.
Each change on the screen should remain for at least 3-6 seconds for the user to perceive it.
The longer the text in toast becomes, the longer the message should be displayed. However, 10-12 seconds should be enough.
If the text is longer than 4 lines, you should consider using an .alert
instead of a .toast
.
Last but not least, if the user moves the mouse or the focus to the .toast
element, the automatic closing should be interrupted/paused and when the mouse/focus leaves the element again, the automatic closing delay should be restarted.
You can stack toasts by wrapping them in a .toast-container
, which will vertically add some spacing.
preview-5491--swisspost-design-system-next.netlify.app/?path=/docs/825b65c9-7eaf-4e0a-9e20-5f5ed406726d--docs&story=Stacked#825b65c9-7eaf-4e0a-9e20-5f5ed406726d--stacked
/?path=/story/825b65c9-7eaf-4e0a-9e20-5f5ed406726d--stacked&full=true
Toasts are intended to be small interruptions to your visitors or users, so to help those with screen readers and similar assistive technologies, you should wrap your toasts in an Live region.
See how to implement it on our live regions documentation.