shadcn.io is not affiliated with official shadcn/ui
Collapsible examples · Standard
Simple Collapsible for React
A ghost Toggle button with a chevron that shows and hides a paragraph below it.
The simplest collapsible: a ghost Toggle Button with a chevron that turns over, and a paragraph that shows and hides below it. Start here and swap in your own content.
Preview
Installation
FAQ
How do I use my own button as the trigger?
The trigger renders our Button with variant="ghost", so it keeps the button's look and the trigger's behavior.
Pass the button as the trigger's render prop.
What does variant ghost change on this button?
It's the transparent button with a hover fill, so the trigger stays quiet next to the content. Any other variant works the same way.
Does the chevron on Toggle rotate?
Yes. The button has the group class and the trigger sets aria-expanded on it while open, so group-aria-expanded:rotate-180 turns the chevron. data-icon="inline-end" spaces it after the label, and aria-hidden keeps the name Toggle.
Related
- Collapsible with IconA Show more information trigger with a
- Inline Trigger CollapsibleA question with an up-down chevron at the
- Text-only CollapsibleA Settings heading with a bracketed
- Card CollapsibleA card with a Features header that
- FAQ Item CollapsibleAn FAQ question with a plus that turns
- Button with Text (Standard)The one filled action