Installation
npx shadcn@latest add @assistant-ui/accordionThe @assistant-ui namespace resolves the Radix or Base UI flavor from your project's style through the style-aware registry entry in components.json. Without that entry, add by direct URL instead:
npx shadcn@latest add https://r.assistant-ui.com/base/accordion.jsonMain Component
npm install @base-ui/react class-variance-authorityUsage
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
export function Example() {
return (
<Accordion defaultValue={["item-1"]}>
<AccordionItem value="item-1">
<AccordionTrigger>Section 1</AccordionTrigger>
<AccordionContent>Content for section 1.</AccordionContent>
</AccordionItem>
<AccordionItem value="item-2">
<AccordionTrigger>Section 2</AccordionTrigger>
<AccordionContent>Content for section 2.</AccordionContent>
</AccordionItem>
</Accordion>
);
}Base UI represents the open value as an array and uses the multiple prop. Radix uses type="single" or type="multiple" and represents a single open value as a string.
Examples
Multiple items open
With icons
Add icons or custom content inside the trigger.
Controlled
Use value and onValueChange for controlled accordion state.
Current value: item-1
FAQ section
Frequently Asked Questions
API Reference
Composable API
| Component | Description |
|---|---|
Accordion | The root component that manages open items. |
AccordionItem | A collapsible section container. |
AccordionTrigger | The control that toggles a section. |
AccordionContent | The collapsible content panel. |
Accordion
AccordionPropsdefaultValue?: string[] | stringThe initial open value. Base UI uses an array; single-value Radix accordions use a string.
value?: string[] | stringThe controlled open value for the selected flavor.
onValueChange?: (value: string[] | string) => voidCalled when the open items change.
multiple: boolean= falseBase UI: whether multiple items can be open.
type?: "single" | "multiple"Radix: whether one or multiple items can be open.
collapsible?: booleanRadix single mode: whether the open item can close.
className?: stringAdditional CSS classes.
AccordionItem
AccordionItemPropsvalue: stringThe unique value for the item.
disabled?: booleanWhether the item is disabled.
className?: stringAdditional CSS classes.
AccordionTrigger
AccordionTriggerPropsclassName?: stringAdditional CSS classes.
AccordionContent
AccordionContentPropsclassName?: stringAdditional CSS classes for the panel content.