Accordion
Accordion organizes content into expandable / collapsible sections to reduce information overload.
Import
Install from npm, copy the source into your project with @yugen-ui/cli or the shadcn CLI, or import directly when working in this repo.
// npm install yugen-uiimport { Accordion, AccordionItem, AccordionHeader, AccordionPanel } from "yugen-ui";Variants
Each tile is a standalone example: hover to copy, or press Code to see the source.
Separated: cards with icon & description
appearance="separated": each item is a card; description is a secondary line under the title (read right after the title, as part of the button's name).
Outline, multiple items & chevron at the end
appearance="outline": one shared border with stroke-2 dividers; type="multiple", expandIconPosition="end", a disabled item.
Nested
An Accordion inside an AccordionPanel inherits the parent's size / expandIconPosition and has a vertical guide line along the start edge.
Size
small, medium (default), large, extra-large.
Usage
- Keep titles short and clear about what's inside; use description for a one-line summary.
- Use separated for settings or FAQ pages that stand out from the background; use outline when the Accordion sits on a surface of the same color.
- Open the most important item by default (defaultValue); use type="multiple" when people need to compare items.
- Don't hide information people must read in a collapsed item.
- Don't nest more than 2 levels. For deeper hierarchies, use Tree.
- Don't mix appearances in one group of items.
Props
| Prop · Type | Default | Description |
|---|---|---|
| type"single" | "multiple" | Default: — | One or several items open at a time (required). |
| collapsibleboolean | Default: false | type="single": lets people close the open item. |
| value / defaultValue / onValueChangestring | string[] | Default: — | Open item(s). |
| appearance"flush" | "separated" | "outline" | Default: "flush" | Continuous · separate cards (rounded-xlarge, shadow-2) · border with dividers. |
| size"small" | "medium" | "large" | "extra-large" | Default: "medium" | Header size; a nested Accordion follows its parent by default. |
| expandIconPosition"start" | "end" | Default: "start" | Chevron position; a nested Accordion follows its parent by default. |
| AccordionItem | Default: — | Item identifier; disables the item. |
| AccordionHeader | Default: — | Size 20 icon before the title. |
| AccordionHeader | Default: — | Secondary line (caption) under the title; part of the button's accessible name (matches the visible text, WCAG 2.5.3). |