About the shadcn/ui Collapsible Component

The Collapsible component is part of shadcn/ui — a collection of accessible, copy-paste React components built with Radix UI and Tailwind CSS. Install it with `npx shadcn@latest add collapsible` and copy it directly into your project.

Collapsible Component — Frequently Asked Questions

How do I control Collapsible open state with React state?

Use `open` and `onOpenChange` props: `<Collapsible open={isOpen} onOpenChange={setIsOpen}>`. This gives full control over when the collapsible opens or closes.

How is shadcn Collapsible different from Accordion?

Collapsible is a single expandable element for one piece of content. Accordion is a group of collapsibles where you can control how many can be open at once.

How do I animate the expand/collapse of shadcn Collapsible?

Use CSS transitions on the content. Add `data-[state=open]:animate-collapsible-down data-[state=closed]:animate-collapsible-up` classes to `<CollapsibleContent>`.

Collapsible Component - shadcn/ui Examples | Shadcn Store