Make your AI a shadcn expert

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.

Scroll to load preview...

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

CollapsibleTrigger
CollapsibleContent

Basic

One trigger, one panel. The chevron rotates when it opens.

Scroll to load preview...

Settings Panel

A Button trigger reveals the extra Fields. The visible pair stays put.

Scroll to load preview...

File Tree

Nest collapsibles. Each folder keeps its own open — they do not close each other.

Scroll to load preview...

RTL

Wrap with DirectionProvider and dir="rtl". Copy and alignment follow the reading direction.

Scroll to load preview...

API

Prop

Type

CollapsibleTrigger

Prop

Type

CollapsibleContent

Prop

Type

CollapsibleTrigger and CollapsibleContent take className. Height animation uses --radix-collapsible-content-height.

Keyboard

KeyAction
Space / EnterToggle 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

Questions

Was this page helpful?

Sign in to leave feedback.