Collapsible

Collapsible panels for sidebar sections, show-more previews, and any secondary content you want out of the way.

Loading preview

Examples

Practical examples and common states for the same installable component.

Card

Collapsible content inside bordered cards.

examples/collapsible-card.tsx
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/wensity/collapsible";
export default function Example() {
return (
<Collapsible variant="card" defaultOpen>
<CollapsibleTrigger>
<div className="flex flex-1 items-center justify-between">
<span>Order #1842</span>
<span className="text-xs font-normal text-[var(--muted-foreground)]">Shipped</span>
</div>
</CollapsibleTrigger>
<CollapsibleContent>
<div className="flex items-center justify-between text-sm text-[var(--muted-foreground)]">
<span>2× Wireless Keyboard</span>
<span className="text-[var(--foreground)]">$158.00</span>
</div>
</CollapsibleContent>
</Collapsible>
);
}

Section

Expandable page sections and settings groups.

examples/collapsible-section.tsx
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/wensity/collapsible";
export default function Example() {
return (
<Collapsible variant="section" defaultOpen>
<CollapsibleTrigger>
<div className="flex flex-col gap-0.5">
<span className="text-[15px] font-medium">Notifications</span>
<span className="text-xs font-normal text-[var(--muted-foreground)]">
Choose what you get notified about
</span>
</div>
</CollapsibleTrigger>
<CollapsibleContent>
<p className="text-sm text-[var(--muted-foreground)]">Product updates: On</p>
</CollapsibleContent>
</Collapsible>
);
}

Sidebar

Collapsible navigation or filter areas.

examples/collapsible-sidebar.tsx
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/wensity/collapsible";
import { IconFile, IconFolder } from "@tabler/icons-react";
export default function Example() {
return (
<Collapsible variant="sidebar" defaultOpen>
<CollapsibleTrigger>
<div className="flex items-center gap-2">
<IconFolder className="size-4 text-[var(--muted-foreground)]" stroke={1.75} />
<span>lib</span>
</div>
</CollapsibleTrigger>
<CollapsibleContent>
<div className="flex items-center gap-2.5 rounded-full px-3 py-2 text-[14px] text-[var(--muted-foreground)]">
<IconFile className="size-4" stroke={1.75} />
<span>utils.ts</span>
</div>
</CollapsibleContent>
</Collapsible>
);
}

Preview

Shows summary first, then full content.

examples/collapsible-preview.tsx
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/wensity/collapsible";
export default function Example() {
return (
<div className="flex h-[240px] w-full max-w-md items-end">
<Collapsible variant="preview" previewHeight={96} className="w-full">
<CollapsibleContent className="rounded-2xl border border-zinc-200/80 bg-white p-5 dark:border-white/[0.06] dark:bg-[#0c0c0e]">
<p className="text-sm leading-relaxed text-[var(--muted-foreground)]">
Our platform gives teams a single source of truth for design and code...
</p>
</CollapsibleContent>
<CollapsibleTrigger
hideIcon
className="w-auto rounded-md px-0 py-1 text-sm font-semibold underline-offset-4 hover:underline focus-visible:underline"
>
{({ open }) => (
<span>{open ? "Show less" : "Show more"}</span>
)}
</CollapsibleTrigger>
</Collapsible>
</div>
);
}

Props

PropTypeDefaultDescription
variant"inline" | "card" | "section" | "sidebar" | "preview""inline"Surface treatment. preview clips content to a fixed height instead of hiding it.
openboolean-Controlled open state.
defaultOpenbooleanfalseInitial open state when uncontrolled.
onOpenChange(open: boolean) => void-Called when the panel opens or closes.
previewHeightnumber96Visible height in pixels while collapsed, for the preview variant.
disabledbooleanfalsePrevents the panel from being toggled.