Accordion
A stack of expandable sections on Ark UI's Accordion machine. Content animates via the kit's own zero-JS Collapse primitive, not Ark's JS-measured height.
Accordion is a stack of expandable sections: each item is a heading wrapping a trigger button, and clicking it reveals that item's panel. Content never animates via Ark's own JS-measured height — the same category of runtime-measurement quirk this kit already worked around for Slider's thumbSize — instead every panel renders through Collapse, this kit's own zero-JS, CSS-grid-rows animation primitive.
import { Accordion } from '@42-central/ui-react/accordion';
<Accordion
data={[
{ value: 'shipping', label: 'Shipping', content: 'Orders ship within 2 business days.' },
{ value: 'returns', label: 'Returns & refunds', content: 'Returns accepted within 30 days.' },
]}
/>Playground
Component
Dir
Presets
Props
Code
<Component
variant="default"
size="md"
radius="sm"
chevronPosition="end"
multiple={false}
collapsible={false}
wrap={false}
/>Items
data is a flat array of { value, label, content, disabled?, icon?, wrap? } — each section needs its own content, so (unlike SegmentGroup) there's no bare-string shorthand.
<Accordion
data={[
{ value: 'shipping', label: 'Shipping', content: <Shipping /> },
{ value: 'returns', label: 'Returns & refunds', content: <Returns /> },
{ value: 'payment', label: 'Payment methods', content: <Payment />, disabled: true },
]}
/>Each item also accepts an optional testId, defaulting to `accordion-${value}` — the matching content panel gets `${testId}-content`. See the Testing guide. The compound Accordion.Item / Accordion.ItemTrigger / Accordion.ItemContent / Accordion.Root parts each take their own testId prop directly, for the same reason.
Variants
Two treatments — a different vocabulary than Button's own filled/light/outline/subtle. default is a single bordered list with dividers between items; separated lays each item out as its own bordered card with a gap between them, its border deepening to a solid neutral ink while open. radius (ignored by default) rounds the separated cards.
Code
<Accordion variant="default" data={[{ value: 'a', label: 'Shipping', content: 'Ships in 2 days.' }, { value: 'b', label: 'Returns', content: 'Accepted within 30 days.' }]} />
<Accordion variant="separated" data={[{ value: 'a', label: 'Shipping', content: 'Ships in 2 days.' }, { value: 'b', label: 'Returns', content: 'Accepted within 30 days.' }]} />Sizes
Five sizes — xs through xl — matching the rest of the family. Sizing lives on the triggers and panels.
Code
<Accordion size="xs" data={[{ value: 'a', label: 'Shipping', content: 'Ships in 2 days.' }]} defaultValue={['a']} />
<Accordion size="md" data={[{ value: 'a', label: 'Shipping', content: 'Ships in 2 days.' }]} defaultValue={['a']} />
<Accordion size="xl" data={[{ value: 'a', label: 'Shipping', content: 'Ships in 2 days.' }]} defaultValue={['a']} />Multiple
By default only one section can be open at a time. Pass multiple to let any number stay expanded together.
Collapsible
In single mode (the default), the one open section can't be closed by re-clicking its own trigger — some other section must be opened instead. Pass collapsible to allow closing it directly, leaving every section collapsed.
Chevron
chevronPosition ("start" | "end", default "end") is a logical position, not a physical left/right — it flips correctly under dir="rtl" with no extra CSS (the same convention Divider's labelPosition uses).
Icons
icons replaces the kit's own icons, per instance: a partial map with one slot, chevron. A key left out (or set to undefined) keeps the default, and chevron: null hides the indicator. There's no separate flag to keep the default icon but stop its open/close rotation: the indicator turns over whatever icon it holds.
Your icon is drawn as given: the indicator sizes it (16px) but doesn't restroke it, so add className={iconStroke} (from @42-central/ui-react) for the kit's 1.5px line. The default chevron points down and needs no mirroring; if yours points along the inline axis, add rtl:-scale-x-100 to it yourself, since the kit only flips its own icons under right-to-left.
Code
import { iconStroke } from '@42-central/ui-react';
import { CircleArrowDown } from 'lucide-react';
<Accordion icons={{ chevron: <CircleArrowDown className={iconStroke} /> }} data={SECTIONS} />
<Accordion icons={{ chevron: null }} data={SECTIONS} />The flat chevron prop it replaces still works for one minor and is deprecated: icons.chevron wins when both are set.
Wrap
Labels truncate with an ellipsis by default. For an FAQ-style accordion, where the question is the label, pass wrap to let it run onto several lines instead. The chevron (and any leading icon) stays aligned with the label's first line rather than centring on the block. Wrapping is opt-in, so existing accordions look the same.
In the data form, a per-item wrap does the same: leave it out to inherit the root's, or set it to override. On Accordion.Item, wrap overrides the root's: wrap={false} keeps one item truncated inside a wrapping accordion, and wrap on a single item wraps just that one.
Code
<Accordion wrap data={FAQ} />Disabled
A single item can be disabled via { value, label, content, disabled: true } — it's skipped by keyboard navigation and can't be opened. Pass disabled on Accordion itself to disable every item at once.
Compound API
Drop to the composable parts for anything the flat data array can't express — custom trigger content, interleaved non-item elements, or driving the value from your own state. variant / size / radius / chevronPosition / icons / order / wrap all live on Accordion.Root — there's no separate List part the way Tabs has one, since the root itself is the list — and cascade to every item through context.
'use client';
import { Accordion } from '@42-central/ui-react/accordion';
<Accordion.Root variant="separated" defaultValue={['shipping']}>
<Accordion.Item value="shipping">
<Accordion.ItemTrigger>Shipping</Accordion.ItemTrigger>
<Accordion.ItemContent>Orders ship within 2 business days.</Accordion.ItemContent>
</Accordion.Item>
<Accordion.Item value="returns">
<Accordion.ItemTrigger>Returns & refunds</Accordion.ItemTrigger>
<Accordion.ItemContent>Returns accepted within 30 days.</Accordion.ItemContent>
</Accordion.Item>
</Accordion.Root>Controlled
Drive the value from state with the same value / onChange pair either way: the data-driven form takes them as top-level props, and the compound Accordion.Root accepts them too — it flattens Ark's own onValueChange into onChange for you, so onValueChange isn't a prop on either form.
'use client';
import { useState } from 'react';
import { Accordion } from '@42-central/ui-react/accordion';
export function FaqAccordion() {
const [open, setOpen] = useState<string[]>(['shipping']);
return (
<Accordion
value={open}
onChange={setOpen}
data={[
{ value: 'shipping', label: 'Shipping', content: <Shipping /> },
{ value: 'returns', label: 'Returns & refunds', content: <Returns /> },
]}
/>
);
}API
Prop
Type
Accessibility
- Built on Ark UI's Accordion machine and the WAI-ARIA Accordion pattern: each trigger is a real
<button>wrapped in a heading (<h2>..<h6>viaorder, default<h3>), witharia-expandedandaria-controlslinking it to itsrole="region"panel. ↓/↑(or→/←whenorientation="horizontal") move focus between triggers and wrap;Home/Endjump to the first/last trigger.Enter/Spacetoggles the focused trigger, same as any native button.- A
disableditem's trigger is a real disabled<button>— skipped by arrow-key navigation and unclickable. - RTL is honored via the document
dir;chevronPositionis logical (start/end), not physical.
Changelog
DataList
A key/value description list on a semantic dl, for profile and detail pages. Labels line up in a column, stack above their values, or switch with the list's width. Pure Server Component.
Tree
A standalone tree view on Ark UI's tree-view machine, for repo file trees and curriculum hierarchies. Same data as TreeSelect, children animate through Collapse.