Accordion
Sections that each open and close under their heading: one at a time, or several.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
sections | { id: string; title: string; body: string }[] | The sections, each with an id, a heading and its text. | |
open | string[] | bindable([]) | The ids of the open sections. Bind it with bind:open={name}. |
multiple | boolean | false | Several sections may be open at once; otherwise opening one closes the others. |
States
| State | Looks like |
|---|---|
closed | The heading only, with a chevron pointing down. |
open | The section's text under its heading; the chevron turns up. |
Accessibility
| role | none; each heading is a button |
| name | Each heading's title. |
| focus | Tab reaches each heading in turn. |
| keyboard | Enter and Space open or close the section. |
| notes | Each heading says expanded or collapsed (aria-expanded) and controls its section. |
Theme tokens
color.surface color.border color.ink color.muted space.4 text.label text.body
Example
<Accordion sections={[{ id: "ship", title: "Shipping", body: "Two to four days." }]} bind:open={open} />