Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Collapsible examples · Card

Nested Card Content Collapsible for React

A Product Details card that expands to its dimensions, weight and material in divided rows.

Framework
UI library

A card that keeps product specifications out of the way until they're wanted. The Product Details header opens to three rows, Dimensions, Weight and Material, divided by lines and written as a description list. Use it on product pages, order details and spec sheets.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

Where is the chevron on Product Details?

At the end of the header row: the trigger is justify-between, and the chevron turns over while the card is open. The trigger has the group class and sets aria-expanded while open, so group-aria-expanded:rotate-180 on ChevronDownIcon turns it, eased by transition-transform duration-200.

How are Dimensions, Weight, and Material separated?

They are a dl with divide-y, which draws a line between rows. Each row is a div with p-4 holding a dt for the label and a dd for the muted value.

How do I add another spec?

Add an entry to the details list at the top of the file. Each entry has a label and a value, and the list renders one row per entry.

What draws the card?

Collapsible has rounded-lg border bg-card text-card-foreground shadow-sm. The trigger tints with hover:bg-muted/50, and CollapsibleContent adds a border-t above the rows.

How do I start Product Details open?

Set defaultOpen on Collapsible.

The card starts closed.

How do I open Product Details from the keyboard?

Tab reaches the trigger, a button named Product Details, and Space or Enter shows or hides the rows.