Display
Accordion
Reveal sections in place.
Usage
An accordion is a stack of headings that each reveal a region. Height animates on the smooth spring and follows the content, with nothing measured in JavaScript. type="single" keeps one item open; type="multiple" allows any number.
When to use
- Content that people scan and open selectively: FAQs, settings groups, filters.
- Use Collapsible for a single region (“show more”).
Not for: content everyone needs to read (just show it), switching between peer views (use tabs).
Variants
default divides items with a line, cards separates them as surfaces, flush drops the lines and tightens the spacing. Items can be disabled one by one or all at once.
default
cards
flush
Collapsible
Collapsible, CollapsibleTrigger and CollapsibleContent are the same animated region without the group: one trigger, one region, open / defaultOpen / onOpenChange.
Changed files
6 files in this commit
package.json
- tsconfig.json
- next.config.ts
- tailwind.config.ts
- .env.example
- README.md
Find in page
Closed content stays in the DOM with hidden="until-found". In browsers that support it (Chromium), Ctrl + F finds text inside a closed item and opens it. Elsewhere the content is hidden normally.
API
Accordion
| Prop | Type | Default | Description |
|---|---|---|---|
| type | 'single' | 'multiple' | — | Required. One open item at a time, or any number. |
| value | string | string[] | — | Controlled open item(s): a string for single, an array for multiple. |
| defaultValue | string | string[] | — | Initially open item(s) when uncontrolled. |
| onValueChange | (value) => void | — | Called with the new value (string for single, string[] for multiple). |
| collapsible | boolean | false | single only: allow the open item to be closed again. |
| variant | 'default' | 'cards' | 'flush' | 'default' | Divided, separated surfaces, or flush. |
| disabled | boolean | false | Disable every item. |
AccordionItem
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | — | Required. Identifies the item in the accordion value. |
| disabled | boolean | — | Disable this item. |
AccordionTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| headingLevel | 2 | 3 | 4 | 5 | 6 | 3 | Heading that wraps the button, so the outline fits your page. |
Collapsible
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | — | Controlled open state. |
| defaultOpen | boolean | false | Initial state when uncontrolled. |
| onOpenChange | (open: boolean) => void | — | Called when the region asks to open or close. |
| disabled | boolean | false | Ignore the trigger. |
CollapsibleTrigger accepts asChild to use your own button. AccordionContent and CollapsibleContent hold the revealed content.
Keyboard
| Key | Action |
|---|---|
| Enter / Space | Opens or closes the focused item. |
| ↓ | Moves focus to the next header; wraps around. |
| ↑ | Moves focus to the previous header; wraps around. |
| Home / End | First / last header. |
| Tab | Moves through headers and the focusable content of open items. |
Accessibility
- Follows the WAI-ARIA accordion pattern: each trigger is a button inside a heading with aria-expanded and aria-controls; the region is labelled by its trigger.
- Closed content is not focusable and not read by screen readers.
- Disabled items stay in the order but cannot be opened or focused.
Motion
- Open: the row grows from 0 to its content height on the smooth spring (about 540ms, no overshoot) while the content fades in.
- Close: 260ms, so it leaves quicker than it arrives. The chevron turns 180 degrees in 220ms.
- An item that starts open does not animate on load.
- Reduced motion: it opens and closes without movement.