Accordion
A headless disclosure primitive: a vertical (or horizontal) stack of collapsible sections with roving focus, single or multiple expansion, disabled items, and controlled/uncontrolled open state.
Anatomy
Provide a unique value on every Accordion.Item — the matching Header, Trigger and Panel read it from the item context, so you only declare it once.
<script>
import { Accordion } from '@human-kit/ui';
</script>
<Accordion.Root defaultValue={['overview']}>
<Accordion.Item value="overview">
<Accordion.Header>
<Accordion.Trigger>Overview</Accordion.Trigger>
</Accordion.Header>
<Accordion.Panel>Overview content</Accordion.Panel>
</Accordion.Item>
</Accordion.Root>Multiple expansion and disabled items
Set selectionMode="multiple" to allow more than one panel open at a time (default is "single"). Use disabled on Accordion.Item to disable a single item, or on Accordion.Root to disable the whole accordion.
Usage guidelines
- Use
value/onChangefor controlled state anddefaultValuefor uncontrolled state. Both are arrays of open item values. - Use
disallowEmptySelectionto keep at least one panel open. - Use
orientation="horizontal"to switch the arrow-key navigation axis. - Use
loop={false}to stop focus from wrapping at the first and last triggers. - Use
forceMountonAccordion.Panelwhen collapsed panel content must stay in the DOM. - Set
levelonAccordion.Header(1–6, default3) to match the surrounding document outline.
Accessibility
Accordion.Headerrenders a real heading element (<h3>by default) that wraps the trigger button, following the WAI-ARIA accordion pattern.Accordion.Triggerrenders button semantics witharia-expandedandaria-controls.Accordion.Panelrendersrole="region"andaria-labelledbypointing at its trigger, and ishidden+inertwhile collapsed.- Arrow keys move focus between triggers, Home/End jump to the first or last enabled trigger, and focus wraps at the ends unless
loop={false}. - Enter/Space toggle the focused panel via native button activation.
API reference
Root
Groups all items and manages selection state and roving focus.
* required. Native HTML attributes of the underlying element are also accepted.
Item
Wraps one collapsible section. Provides its value to Header, Trigger and Panel via context.
* required. Native HTML attributes of the underlying element are also accepted.
Header
A real heading element (h3 by default) wrapping the trigger.
* required. Native HTML attributes of the underlying element are also accepted.
Trigger
The button that toggles its panel. Exposes aria-expanded and aria-controls.
* required. Native HTML attributes of the underlying element are also accepted.
Panel
The collapsible region, hidden and inert while collapsed.
* required. Native HTML attributes of the underlying element are also accepted.