Accordion
An Accordion is used to hide/show content via the use of child Panel elements.
The Accordion has three style variants:
borderno-bordernaked
Use soloExpandable when only one panel should stay open at a time.
Use iconType="chevron" for a rotating chevron, or iconType="plus-minus" for plus/minus icons.
Import
- React
- Angular
- Vue.js
// with @dhl-official/react-library:
import { DhlAccordion, DhlPanel } from "@dhl-official/react-library"
// with @dhl-official/ui-libraries/react-library:
import { DhlAccordion, DhlPanel } from "@dhl-official/ui-libraries/react-library"
If the DUIL has been installed, you can use the web component directly:
<dhl-accordion></dhl-accordion>
<dhl-panel></dhl-panel>
If the DUIL has been installed, you can use the web component directly:
<dhl-accordion></dhl-accordion>
<dhl-panel></dhl-panel>
Accessibility
To ensure the Accordion component is accessible, its children Panel elements are required to have a heading slot.
The properties headingId and panelId are used to internally set the aria-controls and aria-labelledby attributes on the
Panel and its child Headline elements. They default to random values, but can be set to a specific value if required.
Notes
- To set the heading text, ensure the container element uses
headingas it's slot value.
Code
- React
- Angular
- Vue.js
<DhlAccordion variant="border">
<DhlPanel>
<span slot="heading">First heading</span>
<DhlText>This is the content related to the first headline</DhlText>
</DhlPanel>
<DhlPanel>
<span slot="heading">Second heading</span>
<DhlText>This is the content related to the second headline</DhlText>
</DhlPanel>
<DhlPanel>
<span slot="heading">Third heading</span>
<DhlText>This is the content related to the third headline</DhlText>
</DhlPanel>
</DhlAccordion>
<duil301-dhl-accordion variant="border">
<duil301-dhl-panel>
<span slot="heading">First heading</span>
<duil301-dhl-text>This is the content related to the first headline</duil301-dhl-text>
</duil301-dhl-panel>
<duil301-dhl-panel>
<span slot="heading">Second heading</span>
<duil301-dhl-text>This is the content related to the second headline</duil301-dhl-text>
</duil301-dhl-panel>
<duil301-dhl-panel>
<span slot="heading">Third heading</span>
<duil301-dhl-text>This is the content related to the third headline</duil301-dhl-text>
</duil301-dhl-panel>
</duil301-dhl-accordion>
<duil301-dhl-accordion variant="border">
<duil301-dhl-panel>
<span slot="heading">First heading</span>
<duil301-dhl-text>This is the content related to the first headline</duil301-dhl-text>
</duil301-dhl-panel>
<duil301-dhl-panel>
<span slot="heading">Second heading</span>
<duil301-dhl-text>This is the content related to the second headline</duil301-dhl-text>
</duil301-dhl-panel>
<duil301-dhl-panel>
<span slot="heading">Third heading</span>
<duil301-dhl-text>This is the content related to the third headline</duil301-dhl-text>
</duil301-dhl-panel>
</duil301-dhl-accordion>