Accordions

Divide content into collapsible sections.

javascript
import { AccordionGroup, AccordionItem } from '@brainandbones/skeleton';

Examples

Does Skeleton come with an Accordion component?

Lorem ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis eaque nam deleniti rem incidunt.

Lorem ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis eaque nam deleniti rem incidunt.

Lorem ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis eaque nam deleniti rem incidunt.

Customized

Icon and Heading

The content for the first element.

The content for the second element.

The content for the third element.

Usage

html
<AccordionGroup>
    <AccordionItem open>
        <svelte:fragment slot="summary">Summary 1</svelte:fragment>
        <svelte:fragment slot="content"><p>Content 1</p></svelte:fragment>
    </AccordionItem>
    <AccordionItem>
        <svelte:fragment slot="summary">Summary 2</svelte:fragment>
        <svelte:fragment slot="content"><p>Content 2</p></svelte:fragment>
    </AccordionItem>
    <AccordionItem>
        <svelte:fragment slot="summary">Summary 3</svelte:fragment>
        <svelte:fragment slot="content"><p>Content 3</p></svelte:fragment>
    </AccordionItem>
</AccordionGroup>

Properties

Accordion Group

Prop Type Default Description
collapsebooleantrueEnable auto-collapse mode.
spacingstringspacing-y-2Provide classes to set spacing between item rows.

Accordion Item

Prop Type Default Description
openbooleanfalseDefines the default open state on page load.
hoverstringhover:bg-primary-500/10Provide classes to set the hover background color.
spacingstringspace-y-0Provide classes to set spacing between title and description elements.
paddingstringpx-4 py-2Provide classes to set padding for summary and content regions.
roundedstringroundedProvide classes to set summary border radius.

Slots

Accordion Item

Name Required Style Prop Description
lead-slotSummary > .summary-leadAllows for an optional leading element, such as an icon.
summaryslotSummaryProvide the summary details of each item.
contentslotContentProvide the content details of each item.

Accessibility

Accordion Item

ARIA Guidelines
Prop Description
summaryIdProvide semantic ID for ARIA summary element.
contentIdProvide semantic ID for ARIA content element.

Keyboard Interactions

Keys Description
TabMoves focus to the next focusable element.
Shift + Tab Moves focus to the previous focusable element.
Space or EnterWhen focus is on the accordion header toggles the collapsable region open/closed.