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.
A banner shows general notifications for a product or system, not a specific task and should therefore not require the user to take immediate action. Banners can persist across multiple sessions.
Banners are intended to attract the user's attention without interrupting their ongoing task.
There are various methods to integrate this component into your project.
We advise opting for the "Standard HTML" approach for banners that remain static on the page and using the "Web Component" method for dismissible banners.
next.design-system.post.ch/?path=/docs/105e67d8-31e9-4d0b-87ff-685aba31fd4c--docs&story=Default#105e67d8-31e9-4d0b-87ff-685aba31fd4c--default
/?path=/story/105e67d8-31e9-4d0b-87ff-685aba31fd4c--default&full=true
<div role="alert" class="banner banner-neutral banner-action"> <div class="banner-content"> <p>This is the content of the banner. It helps to draw attention to critical messages.</p> </div> <div class="banner-buttons"> <button class="btn btn-primary"> <span>Accept</span> </button> <button class="btn btn-secondary"> <span>Cancel</span> </button> </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/banner.scss';
Banners can be used as a dialog that opens on top of the current page.
next.design-system.post.ch/?path=/docs/105e67d8-31e9-4d0b-87ff-685aba31fd4c--docs&story=Dialog#105e67d8-31e9-4d0b-87ff-685aba31fd4c--dialog
/?path=/story/105e67d8-31e9-4d0b-87ff-685aba31fd4c--dialog&full=true
Banners can contain various HTML elements like headings, paragraphs, lists and dividers.
next.design-system.post.ch/?path=/docs/105e67d8-31e9-4d0b-87ff-685aba31fd4c--docs&story=Additional Content#105e67d8-31e9-4d0b-87ff-685aba31fd4c--additional-content
/?path=/story/105e67d8-31e9-4d0b-87ff-685aba31fd4c--additional-content&full=true
Banners come with a preassigned icon based on their type.
You have the option to customize this icon by using a post-icon
element inside the banner.
For more information, read the getting started with icons guide.
next.design-system.post.ch/?path=/docs/105e67d8-31e9-4d0b-87ff-685aba31fd4c--docs&story=Custom Icon#105e67d8-31e9-4d0b-87ff-685aba31fd4c--custom-icon
/?path=/story/105e67d8-31e9-4d0b-87ff-685aba31fd4c--custom-icon&full=true
If you prefer not to display any icon, you can add the .no-icon
class to the banner.
next.design-system.post.ch/?path=/docs/105e67d8-31e9-4d0b-87ff-685aba31fd4c--docs&story=No Icon#105e67d8-31e9-4d0b-87ff-685aba31fd4c--no-icon
/?path=/story/105e67d8-31e9-4d0b-87ff-685aba31fd4c--no-icon&full=true
To include action buttons within a banner, apply the .banner-action
class to the banner element,
enclose the banner's content within a .banner-content
container, and place the action buttons within a .banner-buttons
wrapper.
next.design-system.post.ch/?path=/docs/8fd36823-966e-46a8-8432-a4439f6e208f--docs&story=Default#8fd36823-966e-46a8-8432-a4439f6e208f--default
/?path=/story/8fd36823-966e-46a8-8432-a4439f6e208f--default&full=true
Reset Banner<post-banner ><p> This is the content of the banner. It helps to draw attention to critical messages. </p></post-banner >
Name | Description | Default | Control |
---|---|---|---|
content | |||
innerHTML | Defines the HTML markup contained in the banner. string | - | |
props | |||
dismissible | If true , a close button (×) is displayed and the banner can be dismissed by the user.boolean | false | |
icon | The icon to display in the banner. By default, the icon depends on the banner type. If string | ||
type | The type of the banner. "danger""info""neutral""success""warning" | 'neutral' | |
events | |||
postDismissed | An event emitted when the banner element is dismissed, after the transition. It has no payload and only relevant for dismissible banners. void | - | - |
methods | |||
dismiss | Triggers banner dismissal programmatically (same as clicking on the close button (×)). dismiss() => Promise<void> | - | - |
slots | |||
actions | Slot for placing custom actions (buttons, links, etc.) within the banner. other | - | - |
default | Slot for placing the main content/message of the banner. other | - | - |
heading | Slot for placing custom content within the banner's heading. other | - | - |
The <post-banner>
element is part of the @swisspost/design-system-components
package.
For more information, read the getting started with components guide.
Banners can contain various HTML elements like paragraphs, lists, icons and dividers.
By default all children of the <post-banner>
are placed in the body.
Use the heading
slot to place a child in the heading, and the actions
slot for action buttons.
Learn more about slots in the mdn web docs.
next.design-system.post.ch/?path=/docs/8fd36823-966e-46a8-8432-a4439f6e208f--docs&story=Contents#8fd36823-966e-46a8-8432-a4439f6e208f--contents
/?path=/story/8fd36823-966e-46a8-8432-a4439f6e208f--contents&full=true
Reset BannerBanners come with a preassigned icon based on their type.
You have the option to customize this icon by assigning the desired icon's name to the icon
property of the banner.
Find the icon you need with the icon search page.
next.design-system.post.ch/?path=/docs/8fd36823-966e-46a8-8432-a4439f6e208f--docs&story=Custom Icon#8fd36823-966e-46a8-8432-a4439f6e208f--custom-icon
/?path=/story/8fd36823-966e-46a8-8432-a4439f6e208f--custom-icon&full=true
Reset BannerIf you prefer not to display any icon, you can set the icon
property to none
.
next.design-system.post.ch/?path=/docs/8fd36823-966e-46a8-8432-a4439f6e208f--docs&story=No Icon#8fd36823-966e-46a8-8432-a4439f6e208f--no-icon
/?path=/story/8fd36823-966e-46a8-8432-a4439f6e208f--no-icon&full=true
Reset BannerThe dismissible
property can be set to enable users to dismiss the banner.
When present, it specifies that the banner should contain a dismiss button,
and you must provide a label for this button using the dismiss-label
property.
Although the label remains hidden from view, it is essential for ensuring accessibility for users of assistive technologies.
next.design-system.post.ch/?path=/docs/8fd36823-966e-46a8-8432-a4439f6e208f--docs&story=Dismissible#8fd36823-966e-46a8-8432-a4439f6e208f--dismissible
/?path=/story/8fd36823-966e-46a8-8432-a4439f6e208f--dismissible&full=true
Reset BannerAlternatively, you can use any button, including action buttons within the banner, as a trigger for dismissing the banner using the .dismiss()
method.
This method operates asynchronously and returns a promise that resolves once the fade-out animation has finished.
const banner = document.getElementById('bannerId') as HTMLPostBannerElement; banner.dismiss().then(() => {});