Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Collapsible

FreeNew

A section that opens to its measured height behind a trigger with a turning chevron.

Installation

pnpm dlx shadcn@latest add @viewport/collapsible

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above.

collapsible-demo.tsx
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/viewport/collapsible";

export default function CollapsibleDemo() {
  return (
    <div className="w-full max-w-sm rounded-2xl border border-border bg-card p-4">
      <p className="text-sm font-medium">Send a weekly summary</p>
      <p className="mt-1 text-[13px] text-muted-foreground">Every Monday at 9:00, to you.</p>
      <Collapsible className="mt-3 border-t border-border pt-2">
        <CollapsibleTrigger className="text-muted-foreground hover:text-foreground">Advanced settings</CollapsibleTrigger>
        <CollapsibleContent className="flex flex-col gap-2 pb-1 ps-6 pt-2 text-[13px] text-muted-foreground">
          <p>Time zone: Central European Time</p>
          <p>Include: new deals, stage changes, overdue tasks</p>
          <p>Format: one email with a CSV attached</p>
        </CollapsibleContent>
      </Collapsible>
    </div>
  );
}

Props

PropTypeDefault
plainboolean

Hide the chevron, e.g. when the trigger is a custom button.

false

Accessibility

  • Built on Radix Collapsible: a button with aria-expanded that controls the region.
  • Closed content is hidden from assistive technology and from Tab.
  • Respects prefers-reduced-motion.