Accordion
A vertically stacked set of interactive headings that each reveal a section of content.
Yes. It adheres to the WAI-ARIA design pattern.
Installation
pnpm dlx cubix@latest add accordion --base radixUsage
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/cubix/accordion"<Accordion defaultValue={["item-1"]} className="w-full">
<AccordionItem value="item-1">
<AccordionTrigger>Is it accessible?</AccordionTrigger>
<AccordionContent>
Yes. It adheres to the WAI-ARIA design pattern.
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-2">
<AccordionTrigger>Is it styled?</AccordionTrigger>
<AccordionContent>
Yes. It comes with default styles that match the other Cubix
components.
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-3">
<AccordionTrigger>Is it animated?</AccordionTrigger>
<AccordionContent>
Yes. The content opens and closes with a height animation.
</AccordionContent>
</AccordionItem>
</Accordion>Examples
Multiple
Set multiple to keep more than one item open at a time.
Yes. Pass multiple to keep more than one section open.
Pass an array to defaultValue or value when multiple is set.
Single item
Omit multiple so only one item is open at a time. Click the open item to close it.
Opening another item closes this one. Click the trigger again to collapse it.
Disabled
This item can be opened and closed.
RTL
Wrap the accordion in dir="rtl" and lang="fa" so layout, chevron placement, and IRANSans XV follow Persian.
بله. از الگوی WAI-ARIA پیروی میکند.
API Reference
Accordion
The root that manages open state and keyboard movement between triggers.
| Prop | Type | Default | Description |
|---|---|---|---|
| multiple | boolean | false | When true, more than one item can stay open at a time. |
| value | string[] | - | Controlled open values. |
| defaultValue | string[] | - | Initial open value(s) for uncontrolled usage. |
| onValueChange | (value: string[]) => void | - | Called when the open value(s) change. |
| className | string | - | Additional Tailwind classes merged with the root styles (last one wins). |
AccordionItem
A single section. Wrap a trigger and content and give it a unique value.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Unique value used to control this item. Required. |
| disabled | boolean | false | Disables the trigger and prevents this item from opening. |
| className | string | - | Additional Tailwind classes merged with the item styles (last one wins). |
AccordionTrigger
The heading button that opens and closes the section.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the trigger styles (last one wins). |
| ...props | React.ComponentProps<'button'> | - | All native button attributes are forwarded to the trigger. |
AccordionContent
The collapsible panel revealed by the trigger.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the content styles (last one wins). |
| ...props | React.ComponentProps<'div'> | - | All native div attributes are forwarded to the content panel. |