Collapsible
One region that opens and closes under its trigger. Where Accordion manages a set of items, Collapsible is the single building block: a "show more", a file tree, an advanced section.
Install
npx shadcn@latest add @nelumbo/collapsibleShow more
The chevron prop adds a trailing chevron that turns on a spring. The extra rows grow in with a height animation and a fade.
Reviewers
- Maya KowalskiApproved
- Kenji WatanabeRequested changes
- Léa MartinApproved
Repository files
Nest them: each folder is a Collapsible, and CollapsibleChevron takes any glyph and any rotation.
- app.tsx
- package.json
With a button
Use asChild to make any Nelumbo button the trigger and drop CollapsibleChevron inside it.
Usage
import { Collapsible, CollapsibleTrigger, CollapsibleContent, CollapsibleChevron } from "@/components/ui/collapsible"<Collapsible> <CollapsibleTrigger chevron>Show 3 more</CollapsibleTrigger> <CollapsibleContent>…</CollapsibleContent></Collapsible><Collapsible> <CollapsibleTrigger asChild> <Button variant="secondary">Advanced <CollapsibleChevron /></Button> </CollapsibleTrigger> <CollapsibleContent>…</CollapsibleContent></Collapsible>Props
Other props go to Radix Collapsible (open, defaultOpen, onOpenChange, disabled). Enter and Space toggle.
| Prop | Type | Default | Notes |
|---|---|---|---|
CollapsibleTrigger chevron | boolean | IconName | false | Trailing chevron that turns when open (not with asChild) |
CollapsibleChevron name | IconName | "keyboard_arrow_down" | Rotates 180 degrees on a spring; override with a className for other turns |