Shadcn Collapsible
React collapsible for extra details, settings, and file trees. Built with TypeScript and Tailwind CSS for Next.js using Base UI — one open region you control.
The shadcn collapsible is one trigger and one panel. Click the trigger and the region under it opens. Use it for extra details on a row, advanced settings, or a folder in a tree — anywhere the label is enough until they ask for more.
Looking for a neobrutalism version for shadcn?
Same collapsible, thicker borders. The NeoBrutalism collapsible is the kit if you want that look.
Usage
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible"<Collapsible>
<CollapsibleTrigger>Can I use this in my project?</CollapsibleTrigger>
<CollapsibleContent>
Yes. Free to use for personal and commercial projects. No attribution
required.
</CollapsibleContent>
</Collapsible>open and onOpenChange take over the panel. Skip them and it runs uncontrolled with defaultOpen.
Composition
Basic
One trigger, one panel. The chevron rotates when it opens.
Settings Panel
A Button trigger reveals the extra Fields. The visible pair stays put.
File Tree
Nest collapsibles. Each folder keeps its own open — they do not close each other.
RTL
Wrap with DirectionProvider and dir="rtl". Copy and alignment follow the reading direction.
API
Prop
Type
CollapsibleTrigger
Prop
Type
CollapsibleContent
Prop
Type
CollapsibleTrigger and CollapsibleContent take className. Height animation uses --radix-collapsible-content-height.
Keyboard
| Key | Action |
|---|---|
Space / Enter | Toggle the focused trigger |
Notes
Closed unmounts
Closed content leaves the DOM unless you set forceMount. Form fields inside will not submit while the panel is closed.
Each root is independent. For a list where only one panel should stay open, use Accordion.
With other components
The usual trigger
CardFrame around the panel
FieldExtra settings fields
InputValues in the panel
TabsExplorer chrome
AccordionA one-open list
Questions
Related
Was this page helpful?
Sign in to leave feedback.
Checkbox
React checkbox for terms, filters, and table row selection. Built with TypeScript and Tailwind CSS for Next.js using Base UI — checked, unchecked, or indeterminate.
Combobox
React combobox for searchable country and framework pickers. Built with TypeScript and Tailwind CSS for Next.js using Base UI — type to filter a long list.