Accordion
Accordion
Sections that open in place: the height eases open, the content rises out of a blur a beat later, and opening one folds the other at the same time.
Dependencies
Interaction states
- open — Height eases (420ms), content rises from a blur (300ms, 90ms later), chevron turns.
- close — Content fades fast (160ms) while the height folds.
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/accordionFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Where it’s used
Settings
Advanced options folded under each group.
Filters
Collapsible filter groups in a sidebar.
Order and invoice details
Line items you can open.
Help
Questions inside an app.
What it handles
- Real height — grid-template-rows 0fr → 1fr, eased 420ms.
- Content through a blur — Rises 6px out of a 4px blur, 90ms after the height starts.
- Single or multiple — Folding the old one while the new one opens.
- Keyboard — ↑/↓ between headers, Home/End.
Usage
Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.
import { Accordion } from "@/components/accordion";
<Accordion items={[
{ value: "shipping", title: "Shipping", content: "Ships in 2 days." },
{ value: "returns", title: "Returns", content: "30 days, free." },
]} />Props
| Prop | Type | Description |
|---|---|---|
| items | AccordionItem[] | – · value, title, subtitle, content, disabled. |
| type | "single" | "multiple" | "single" · How many can be open. |
| value / defaultValue | string[] | – · Open sections. |
| onValueChange | (value: string[]) => void | – · Called on change. |
| variant | "rows" | "cards" | "rows" · thin line rows or cards. |
Accessibility & motion
- Headers are buttons in h3s with aria-expanded and aria-controls; panels are regions. - Folded content is inert. - Reduced motion: sections open in place.
pnpm dlx shadcn@4.21.5 add @cavemio/accordion