Components
A vertically stacked set of collapsible sections built on Base UI's Accordion primitive. Supports single or multiple open items, controlled or uncontrolled state, a custom trigger icon, smooth height-animated panels, and nesting. Ships Accordion, AccordionItem, AccordionTrigger and AccordionPanel (also exported as AccordionContent).
Loading preview...
import {
Accordion,
AccordionItem,
AccordionPanel,
AccordionTrigger,
} from "@/components/ui/cnippet-accordion";
export default function AccordionDemo() {
const items = [
{
content:
"Base UI is a library of high-quality unstyled React components for design systems and web apps.",
id: "1",
title: "What is Base UI?",
},
{
content:
"Head to the \"Quick start\" guide in the docs. If you've used unstyled libraries before, you'll feel at home.",
id: "2",
title: "How do I get started?",
},
{
content: "Of course! Base UI is free and open source.",
id: "3",
title: "Can I use it for my project?",
},
];
return (
<Accordion className="mx-auto w-full max-w-xl" defaultValue={["3"]}>
{items.map((item) => (
<AccordionItem key={item.id} value={item.id}>
<AccordionTrigger>{item.title}</AccordionTrigger>
<AccordionPanel>{item.content}</AccordionPanel>
</AccordionItem>
))}
</Accordion>
);
}
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...