Components
Collapsible
A single disclosure for optional detail.
Free
pnpm dlx shadcn@latest add @caliper/collapsibleWhen to use
Use it for
- Advanced options and secondary notes.
- Keeping a page short without hiding the existence of detail.
Skip it when
- Several related items; use an accordion.
Installation
terminal
pnpm dlx shadcn@latest add @caliper/collapsible
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
This is the code behind the preview above.
example.tsx
import { type ReactNode } from "react" import { Avatar } from "@/components/ui/avatar" import { Collapsible } from "@/components/ui/collapsible" import { cn } from "@/components/ui/lib/cn" function Panel({ title, context, media, action, className, children }: { title: string; context: string; media?: ReactNode; action?: ReactNode; className?: string; children?: ReactNode }) { return ( <section className={cn("grid w-full max-w-md gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting", className)}> <div className="flex items-center gap-3"> {media} <div className="grid min-w-0 flex-1 gap-1"> <p className="font-medium">{title}</p> <p className="text-sm text-muted-foreground">{context}</p> </div> {action} </div> {children} </section> ); } export function ArrivalNotes() { return ( <Panel title="Booking HB-2208" context="Aoife Byrne · 8–14 Oct · 2 guests" media={<Avatar name="Aoife Byrne" alt="" />}> <dl className="grid grid-cols-2 gap-4 text-sm"> <div className="grid gap-0.5"><dt className="text-muted-foreground">Room</dt><dd className="m-0 font-medium">Harbour room 4</dd></div> <div className="grid gap-0.5"><dt className="text-muted-foreground">Arriving</dt><dd className="m-0 font-medium">Thu 8 Oct, around 22:30</dd></div> </dl> <Collapsible title="Arrival notes">Late arrivals use the side door on Quay Street and the code 4721 from the booking. The night porter keeps a breakfast box for anyone who misses 10:30.</Collapsible> </Panel> ); }
API reference
Collapsible
component
PropTypeDefault
title *string—
children *ReactNode—
openboolean—
defaultOpenbooleanfalse
onOpenChange((open: boolean) => void)—
classNamestring—
Accessibility
It is built on native elements and keeps aria-expanded, aria-controls and aria-hidden in step with state.
No custom key handling; Tab and the native activation keys do the work.
Motion
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.