No Preview

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:

  1. Missing Context/Providers: You can use decorators to supply specific contexts or providers, which are sometimes necessary for components to render correctly. For detailed instructions on using decorators, please visit the Decorators documentation.
  2. Misconfigured Webpack or Vite: Verify that Storybook picks up all necessary settings for loaders, plugins, and other relevant parameters. You can find step-by-step guides for configuring Webpack or Vite with Storybook.
  3. Missing Environment Variables: Your Storybook may require specific environment variables to function as intended. You can set up custom environment variables as outlined in the Environment Variables documentation.

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.

Title
This is a sample toast message to demonstrate the component functionality.
<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>
NameDescriptionDefaultControl
General
Title
The text to insert into the title area.
string
-
Content
The text to insert into the content area.
string
-
Variant
Defines a style variant.
string
-
No Icon
Removes the predefined icon completely.
boolean
-
Icon
Defines a custom icon.
string
-
Dismissible
Adds a dismiss button.
boolean
-
Positioning
Position
Defines the component's Positioning.
string
-
Vertical
When position set to fixed, defines the component's vertical position.
string
-
Horizontal
When position set to fixed, defines the component's horizontal position.
string
-

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.

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.

Title
This is a sample toast message to demonstrate the component functionality.
Title
This is a sample toast message to demonstrate the component functionality.

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.