Disclosure

Accordion / Collapse

The chevron rotates off the machine's own `data-state` — nothing in JavaScript toggles a class.

data-scope="accordion"

What you get for free

  • Arrow-key navigation, Home and End
  • Correct aria-expanded and region wiring

Usage

<Collapse
  defaultActiveKey={["a"]}
  items={[{ key: "a", label: "Shipping", children: <p>…</p> }]}
/>
<Accordion :items="items" allow-multiple>
  <template #a>…</template>
</Accordion>
<Accordion {items} allowMultiple>
  {#snippet a()}…{/snippet}
</Accordion>
<ck-accordion [items]="items" allowMultiple>
  <ng-template ckPanel="a">…</ng-template>
</ck-accordion>

Props

PropTypeDefaultNotes
activeKey, defaultActiveKeystring | string[]React firstOpen panel keys. A bare string is accepted for the single-panel case.
onChange(key: string[]) => voidReact firstAlways the full open set, even in `accordion` mode where it holds one.
accordionbooleanfalseReact firstOne panel at a time. The inverse of v1's `allowMultiple`: several open is now the default, and this opts out.
itemsAccordionItem[] | CollapseItem[]The panels. v1 items are `{ id, title, content }`; React's v2 items are `{ key, label, children }`.
valuestring[]Not in ReactOpen item ids.
defaultValuestring[]Not in ReactInitially open ids.
allowMultiplebooleanfalseNot in ReactSeveral open at once. v0 called this `multiple`.
collapsiblebooleantrueNot in ReactAllow closing the last open item.

Prop names are identical in all four frameworks. Only two-way binding differs, and each framework uses its own idiom over the same underlying prop. The marked rows are the exception, and a temporary one, in both directions: React first exists in React while the other three adapters catch up, and Not in React is the prop it replaced, still live everywhere else.

Migrating from react-ui-toolkit

v0v1Notes
multipleallowMultiple