Duolith docs

Accordion

Sections that each open and close under their heading: one at a time, or several.

Stability: experimental

Props

PropTypeDefaultMeans
sections{ id: string; title: string; body: string }[]The sections, each with an id, a heading and its text.
openstring[]bindable([])The ids of the open sections. Bind it with bind:open={name}.
multiplebooleanfalseSeveral sections may be open at once; otherwise opening one closes the others.

States

StateLooks like
closedThe heading only, with a chevron pointing down.
openThe section's text under its heading; the chevron turns up.

Accessibility

rolenone; each heading is a button
nameEach heading's title.
focusTab reaches each heading in turn.
keyboardEnter and Space open or close the section.
notesEach 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} />