Skip to content

Accordion

We ship worldwide within 3–5 business days.

Return any item within 30 days.

A WAI-ARIA accordion with single or multiple expansion and arrow movement between headers.

<script>
import Accordion from "@invisible-ui/svelte/Accordion.svelte";
</script>

In Elements:

<ds-accordion value="shipping">
<ds-accordion-item value="shipping" label="Shipping">Ships in 2-3 days.</ds-accordion-item>
<ds-accordion-item value="returns" label="Returns">30-day returns.</ds-accordion-item>
</ds-accordion>

Each <ds-accordion-item> takes value, label and disabled, and its children are the panel content, so a panel can hold any markup.

PropTypeDefaultDescription
items *AccordionEntry[]—
valuestring[][]
typeAccordionType"single"One open at a time, or many.
collapsiblebooleantrueFor single: allow collapsing the open item.
disabledbooleanfalseDisable the whole accordion.
onValueChange((value: string[]) => void) | undefinedundefinedCalled whenever the expanded set changes.
  • WAI-ARIA accordion pattern: header buttons (aria-expanded) linked to regions, arrow/Home/End movement between headers.
  • The chevron points to the end of the line and mirrors in right-to-left text; open, it points down in both directions.
  • For rich panel markup, drive the headless createAccordion directly.
<Accordion
items={[
{ value: "shipping", label: "Shipping", content: "Ships in 2-3 days." },
{ value: "returns", label: "Returns", content: "30-day returns." },
]}
/>

In React, content takes any markup, and headingLevel sets the level of the item headers (3 by default) so they fit the page outline:

<Accordion
headingLevel={2}
value={open}
onValueChange={setOpen}
items={[
{ value: "shipping", label: "Shipping", content: <ShippingTable /> },
{ value: "returns", label: "Returns", content: "30-day returns." },
]}
/>

Themeable via --ds-accordion-*.