Components
Accordion
Expandable sections for settings and detail pages, with single or multiple open items and full keyboard support.
Overview
Accordion renders a list of sections whose bodies expand and collapse under their headers. Pass the sections as items. With type="single" (the default) at most one item is open; with type="multiple" any number can stay open. The open state works controlled (value + onValueChange) or uncontrolled (defaultValue).
Import
import { Accordion } from '@unflowio/ui/components/Accordion';Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | AccordionItem[] | — | Required. The sections, in order |
type | 'single' | 'multiple' | 'single' | single keeps at most one item open; multiple lets any number stay open |
value | string | null (single) / string[] (multiple) | — | Open item(s), controlled. null means none is open |
defaultValue | string | null (single) / string[] (multiple) | — | Initially open item(s), uncontrolled |
onValueChange | (value: string | null) => void (single) / (value: string[]) => void (multiple) | — | Called when an item opens or closes |
collapsible | boolean | true | Single only. Lets the open item be closed again, leaving none open |
headingLevel | 2 | 3 | 4 | 5 | 6 | 3 | Heading level that wraps each header button |
AccordionItem:
| Field | Type | Description |
|---|---|---|
value | string | Required. Unique key, used by value / defaultValue |
title | ReactNode | Required. Header text |
description | ReactNode | Secondary line under the title |
content | ReactNode | Required. Body shown while the item is open |
disabled | boolean | Prevents the item from opening or closing |
Basic usage
Workspace name, default language and time zone.
Choose which events send an email and which only show in the app.
Connect GitHub, Linear and Slack to this workspace.
<Accordion items={items} defaultValue="general" />Multiple
Set type="multiple" to let several items stay open. value and defaultValue become arrays.
Workspace name, default language and time zone.
Choose which events send an email and which only show in the app.
Connect GitHub, Linear and Slack to this workspace.
<Accordion type="multiple" items={items} defaultValue={['general', 'integrations']} />Descriptions and disabled items
description adds a secondary line under the title. A disabled item stays visible but can't be toggled.
main · 3 ignore globs
Two reviewers, one from the owning team.
You do not have access to billing.
Controlled
Open item: notifications
Workspace name, default language and time zone.
Choose which events send an email and which only show in the app.
Connect GitHub, Linear and Slack to this workspace.
const [open, setOpen] = useState<string | null>('notifications');
<Accordion items={items} value={open} onValueChange={setOpen} />Set collapsible={false} on a single accordion to keep one item always open.
Customization (slots & slotProps)
| Slot | Type | Description |
|---|---|---|
icon | ReactNode | Replaces the chevron. It rotates with the open state unless you style it otherwise |
| Slot Prop | Props | Description |
|---|---|---|
item | BaseHTMLProps<HTMLDivElement> | Each item wrapper |
trigger | BaseHTMLProps<HTMLButtonElement> | Each header button |
panel | BaseHTMLProps<HTMLDivElement> | Each body panel |
Accessibility
- Each header is a
<button>inside a heading (headingLevel), witharia-expandedandaria-controlspointing at its panel. - Each panel is a
role="region"labelled by its header. - ArrowDown/ArrowUp move focus between headers, and Home/End jump to the first/last.