Accordion
A compound component for showing and hiding sections of content, supporting single-item and multi-item expansion modes.
Installation
npx @obi/ui add accordionPreview
A copy-paste design system for React — install only what you need.
Usage
import Accordion, {
AccordionItem,
AccordionTrigger,
AccordionContent,
} from '@/src/components/Accordion/Accordion';
export default function Example() {
return (
<div className="max-w-sm">
<Accordion type="single" collapsible defaultValue="item-1">
<AccordionItem value="item-1">
<AccordionTrigger>What is Obi UI?</AccordionTrigger>
<AccordionContent>
Obi UI is a token-based component library for React, built on Tailwind v4.
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-2">
<AccordionTrigger>How do I install it?</AccordionTrigger>
<AccordionContent>
Run npx @obi/ui add [component] to copy any component into your project.
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-3">
<AccordionTrigger>Does it support dark mode?</AccordionTrigger>
<AccordionContent>
Yes — all components use semantic tokens that respond to the .dark class on the root element.
</AccordionContent>
</AccordionItem>
</Accordion>
</div>
);
}Props
| Name | Type | Default | Description |
|---|---|---|---|
| type | "single" | "multiple" | "single" | Whether one or many items can be open at once. |
| defaultValue | string | string[] | — | Item value(s) open on initial render. |
| collapsible | boolean | false | When type is single, whether the open item can be collapsed by clicking again. |
| className | string | "" | Additional classes on the root div. |