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.
Toggle the visibility of a set of related content in your project.
The <post-accordion>
is a container for <post-accordion-item>
components.
It is used to manage how content is shown and hidden across a set of collapsible elements.
next.design-system.post.ch/?path=/docs/4d1b4185-e04d-494a-ab38-2b56c1778b0b--docs&story=Default#4d1b4185-e04d-494a-ab38-2b56c1778b0b--default
/?path=/story/4d1b4185-e04d-494a-ab38-2b56c1778b0b--default&full=true
Example content for accordion item 1. This is a sample text demonstrating how the accordion component works.
Example content for accordion item 2. This is a sample text demonstrating how the accordion component works.
Example content for accordion item 3. This is a sample text demonstrating how the accordion component works.
<post-accordion heading-level="3"> <post-accordion-item> <span slot="header">Title 1</span> <div> <p> Example content for accordion item 1. This is a sample text demonstrating how the accordion component works. </p> </div> </post-accordion-item> <post-accordion-item> <span slot="header">Title 2</span> <div> <p> Example content for accordion item 2. This is a sample text demonstrating how the accordion component works. </p> </div> </post-accordion-item> <post-accordion-item> <span slot="header">Title 3</span> <div> <p> Example content for accordion item 3. This is a sample text demonstrating how the accordion component works. </p> </div> </post-accordion-item> </post-accordion>
<post-accordion>
Name | Description | Default | Control |
---|---|---|---|
props | |||
multiple | If true , multiple post-accordion-item can be open at the same time.boolean | false | |
heading-level* | Defines the hierarchical level of the post-accordion-item headers within the headings structure.123456 | ||
Content | |||
logoSrc | Define an image src to insert a custom image.Do you need an example? Try our logo /assets/images/logo-swisspost.svg. string | - | |
methods | |||
collapseAll | Collapses all post-accordion-item .collapseAll() => Promise<void> | - | - |
expandAll | Expands all If expandAll() => Promise<void> | - | - |
toggle | Toggles the post-accordion-item with the given id.toggle(id: string) => Promise<void> | - | - |
slots | |||
default | Slot for placing post-accordion-item components. other | - | - |
Events | |||
postToggle | An event emitted when a The event payload is a CustomEvent whose target is the toggled CustomEvent<boolean> | - | - |
<post-accordion-item>
Name | Description | Default | Control |
---|---|---|---|
props | |||
collapsed | If true , the element is collapsed otherwise it is displayed.boolean | false | - |
methods | |||
toggle | Triggers the collapse programmatically. toggle(force?: boolean) => Promise<boolean> | - | - |
slots | |||
default | Slot for placing content within the accordion item's body. other | - | - |
header | Slot for placing custom content within the accordion item's header. other | - | - |
logo | Slot for the placing a logo before the header. other | - | - |
css shadow parts | |||
body | The pseudo-element, used to override styles on the components internal body element. | - | - |
button | The pseudo-element, used to override styles on the components internal header button element. | - | - |
The <post-accordion>
element is part of the @swisspost/design-system-components
package.
For more information, read the getting started with components guide.
By default, whenever a panel is opened manually or programmatically, any other open panel is closed.
To allow multiple panels to be open at the same time, use the multiple="true"
property.
next.design-system.post.ch/?path=/docs/4d1b4185-e04d-494a-ab38-2b56c1778b0b--docs&story=Multiple Open Panels#4d1b4185-e04d-494a-ab38-2b56c1778b0b--multiple-open-panels
/?path=/story/4d1b4185-e04d-494a-ab38-2b56c1778b0b--multiple-open-panels&full=true
Example content for accordion item 1. This is a sample text demonstrating how the accordion component works.
Example content for accordion item 2. This is a sample text demonstrating how the accordion component works.
Example content for accordion item 3. This is a sample text demonstrating how the accordion component works.
To enhance individual accordion items with a logo, add an <img>
to the logo slot.
This will display the logo in front of the accordion item's heading.
next.design-system.post.ch/?path=/docs/4d1b4185-e04d-494a-ab38-2b56c1778b0b--docs&story=Logos#4d1b4185-e04d-494a-ab38-2b56c1778b0b--logos
/?path=/story/4d1b4185-e04d-494a-ab38-2b56c1778b0b--logos&full=true
Example content for accordion item 1. This is a sample text demonstrating how the accordion component works.
Example content for accordion item 2. This is a sample text demonstrating how the accordion component works.
Example content for accordion item 3. This is a sample text demonstrating how the accordion component works.
Use the collapsed="true"
property on all post-accordion-item
you want to be initially closed.
The first panel without this property will be initially open,
or if the accordion is configured with the multiple="true"
property, all other panels will be open.
next.design-system.post.ch/?path=/docs/4d1b4185-e04d-494a-ab38-2b56c1778b0b--docs&story=Default Collapsed Panels#4d1b4185-e04d-494a-ab38-2b56c1778b0b--default-collapsed-panels
/?path=/story/4d1b4185-e04d-494a-ab38-2b56c1778b0b--default-collapsed-panels&full=true
Example content for accordion item 1. This is a sample text demonstrating how the accordion component works.
Example content for accordion item 2. This is a sample text demonstrating how the accordion component works.
Example content for accordion item 3. This is a sample text demonstrating how the accordion component works.
To ensure accessibility, all accordion titles are contained within heading tags (h1
-h6
) behind the scenes.
It is essential to set the appropriate heading-level
property on the post-accordion
so that it matches the structure of your page properly.
next.design-system.post.ch/?path=/docs/4d1b4185-e04d-494a-ab38-2b56c1778b0b--docs&story=Nested#4d1b4185-e04d-494a-ab38-2b56c1778b0b--nested
/?path=/story/4d1b4185-e04d-494a-ab38-2b56c1778b0b--nested&full=true
h4
Example content for accordion item 1. This is a sample text demonstrating how the accordion component works.
h5
Example content for accordion item 1.1. This is a sample text demonstrating how the accordion component works.
h5
Example content for accordion item 1.2. This is a sample text demonstrating how the accordion component works.
h5
Example content for accordion item 1.3. This is a sample text demonstrating how the accordion component works.
h4
Example content for accordion item 2. This is a sample text demonstrating how the accordion component works.
h5
Example content for accordion item 2.1. This is a sample text demonstrating how the accordion component works.
h5
Example content for accordion item 2.2. This is a sample text demonstrating how the accordion component works.
h5
Example content for accordion item 2.3. This is a sample text demonstrating how the accordion component works.
h4
Example content for accordion item 3. This is a sample text demonstrating how the accordion component works.
The <post-accordion>
offers several methods to expand or collapse the <post-accordion-item>
it contains.
Expand or collapse all elements at once using .expandAll()
and .collapseAll()
respectively,
or toggle just one using .toggle()
specifying the id of the element you want to act on.
const accordion = document.querySelector('post-accordion') as HTMLPostAccordionElement; accordion.expandAll(); accordion.collapseAll(); accordion.toggle('collapsibleId');