Collapsible
A section that shows and hides its content with a height animation.
"use client"
import { ChevronRightIcon } from "lucide-react"
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
const favorites = ["AirDrop", "Recents", "Applications", "Desktop", "Documents", "Downloads"]
// A sidebar section that hides its items, like Finder's Favorites.
export default function CollapsibleDemo() {
return (
<Collapsible defaultOpen className="w-56 text-mac-body">
<CollapsibleTrigger className="group flex w-full cursor-default items-center justify-between rounded-[6px] px-2 py-1 text-mac-subheadline font-semibold text-mac-label-tertiary outline-none hover:text-mac-label-secondary focus-visible:mac-focus-ring">
Favorites
<ChevronRightIcon className="size-3 transition-transform group-aria-expanded:rotate-90" strokeWidth={2.5} />
</CollapsibleTrigger>
<CollapsibleContent>
<ul className="flex flex-col pt-0.5">
{favorites.map((item) => (
<li key={item} className="rounded-[8px] px-2 py-1.5 text-mac-label">
{item}
</li>
))}
</ul>
</CollapsibleContent>
</Collapsible>
)
}Installation
pnpm dlx shadcn@latest add @cupertinoui/collapsibleThe first install also adds the macOS theme. See Installation to set up the registry.
Usage
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
<Collapsible defaultOpen>
<CollapsibleTrigger>Favorites</CollapsibleTrigger>
<CollapsibleContent>…</CollapsibleContent>
</Collapsible>API Reference
Every part forwards the props of the underlying Base UI Collapsible part. The props below are the ones CupertinoUI adds or changes.
Collapsible
| Prop | Type | Description |
|---|---|---|
open / defaultOpen / onOpenChange | | Whether the content shows. |
className | string | Extra classes, merged with the component's own. |