Collapsible
Collapsible example: an unstyled expandable section with root, trigger and content panel parts. It adds only slot attributes, so the open and closed look is left to you.
pnpm dlx shadcn add @01orbital/collapsible"use client"
import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible"
function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) {
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
}
function CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) {
return (
<CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />
)
}
function CollapsibleContent({ ...props }: CollapsiblePrimitive.Panel.Props) {
return (
<CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />
)
}
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
"use client"
import * as React from "react"
import { CaretUpDownIcon } from "@phosphor-icons/react/dist/ssr"
import { Button } from "@/components/ui/button"
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible"
// The copy: change text here, not in the markup.
const COPY = {
title: "Order #4189",
toggle: "Toggle details",
status: "Status",
shipped: "Shipped",
} as const
const DETAILS = [
{ title: "Shipping address", body: "100 Market St, San Francisco" },
{ title: "Items", body: "2x Studio Headphones" },
] as const
export default function CollapsibleDemo() {
const [isOpen, setIsOpen] = React.useState(false)
return (
<Collapsible
open={isOpen}
onOpenChange={setIsOpen}
className="flex w-[350px] flex-col gap-2"
>
<div className="flex items-center justify-between gap-4 px-4">
<h4 className="text-sm font-semibold">{COPY.title}</h4>
<CollapsibleTrigger
render={<Button variant="ghost" size="icon" className="size-8" />}
>
<CaretUpDownIcon />
<span className="sr-only">{COPY.toggle}</span>
</CollapsibleTrigger>
</div>
<div className="flex items-center justify-between rounded-md border px-4 py-2 text-sm">
<span className="text-muted-foreground">{COPY.status}</span>
<span className="font-medium">{COPY.shipped}</span>
</div>
<CollapsibleContent className="flex flex-col gap-2">
{DETAILS.map((detail) => (
<div
key={detail.title}
className="rounded-md border px-4 py-2 text-sm"
>
<p className="font-medium">{detail.title}</p>
<p className="text-muted-foreground">{detail.body}</p>
</div>
))}
</CollapsibleContent>
</Collapsible>
)
}
Dependencies
npm: @base-ui/react. The CLI installs them for you.
No other registry pieces.