Accordions
Svelte ComponentDivide content into collapsible sections.
Import
Package
Source
Doc
WAI-ARIA
Examples
Icon Heading
Icon Heading
The content for the first element.
Avatar Heading
Avatar Heading
The content for the second element.
Numeral Heading
Numeral Heading
The content for the third element.
Usage
A standard AccordionGroup that only allows one AccordionItem to be open at once.
<AccordionGroup>
<!-- Open -->
<AccordionItem open>
<svelte:fragment slot="lead">(lead)</svelte:fragment>
<svelte:fragment slot="summary">(summary)</svelte:fragment>
<svelte:fragment slot="content">(content)</svelte:fragment>
</AccordionItem>
<!-- Closed -->
<AccordionItem>
<svelte:fragment slot="summary">(summary)</svelte:fragment>
<svelte:fragment slot="content">(content)</svelte:fragment>
</AccordionItem>
</AccordionGroup>
When you don't want an AccordionItem to auto-collapse the other AccordionItems, just set collapse
to false
.
<AccordionGroup collapse={false}>
<!-- Open -->
<AccordionItem open>
<svelte:fragment slot="lead">(lead)</svelte:fragment>
<svelte:fragment slot="summary">(summary)</svelte:fragment>
<svelte:fragment slot="content">(content)</svelte:fragment>
</AccordionItem>
<!-- Closed -->
<AccordionItem>
<svelte:fragment slot="summary">(summary)</svelte:fragment>
<svelte:fragment slot="content">(content)</svelte:fragment>
</AccordionItem>
</AccordionGroup>