Vertically stacked sections that expand to reveal content.
$ pnpm dlx shadcn@latest add https://dashral.com/r/accordion.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/accordion.jsonAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:
components.json
{
"registries": {
"@dashral": "https://dashral.com/r/{name}.json"
}
}Then add components by name:
$ pnpm dlx shadcn@latest add @dashral/accordionUsage
example.tsx
import { Accordion } from "@/components/dashral/accordion"
<Accordion
items={[
{ title: "Can I change plans later?", content: "Yes, upgrade or downgrade at any time." },
{ title: "Do you offer refunds?", content: "In full within 14 days, for any reason." },
]}
/>Examples
API reference
Accordion
Also takes every prop of <div>(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
items | { title, content, value?, disabled? }[]The sections. Required. | — |
multiple | booleanAny number open at once; otherwise opening one closes the other. | false |
value / defaultValue | string[]The open sections (their value, or index), controlled or initial. | — |
onValueChange | (value: string[]) => voidCalled with the new value. | — |
variant | "default" | "separated"Rows split by lines, or each a card of its own. | "default" |
classNames | { item, trigger, content }Classes for each part. | — |
className | stringExtra classes, merged with cn() so yours win. | — |
Keyboard
| Keys | Action |
|---|---|
| EnterorSpace | Open or close the focused section |
| ↓or↑ | Move to the next or previous heading |
| HomeorEnd | Move to the first or last heading |
Accessibility
- Each trigger is a button inside a heading, with aria-expanded and aria-controls pointing at its section.
- Sections are regions labelled by their heading.
Motion
- Sections slide open and closed by their measured height.