StacklyUI
Components/Collapsible

Collapsible

Show and hide a section of content.

01

Preview & playground

Edit the code — the preview updates live. Try changing props, text, or classes.

playground.tsx
function Demo() {
  const [open, setOpen] = useState(false)
  return (
    <Collapsible open={open} onOpenChange={setOpen} className="w-full max-w-sm">
      <div className="flex items-center justify-between rounded-lg border border-border-strong px-4 py-2.5">
        <span className="text-sm font-medium">@stacklyui starred 3 repos</span>
        <CollapsibleTrigger asChild><Button size="sm" variant="ghost">{open ? "Hide" : "Show"}</Button></CollapsibleTrigger>
      </div>
      <CollapsibleContent className="mt-2 space-y-2">
        <div className="rounded-lg border border-border px-4 py-2 text-sm">@stacklyui/ui</div>
        <div className="rounded-lg border border-border px-4 py-2 text-sm">stackly-docs</div>
      </CollapsibleContent>
    </Collapsible>
  )
}
render(<Demo />)
02

Installation

Copy the source into your project with the registry CLI:

$pnpm dlx shadcn@latest add @stacklyui/collapsible

Or install the package and import it:

$pnpm add @stacklyui/ui motion
03

Usage

Import Collapsible from "@stacklyui/ui" and compose it as shown in the playground above. Every interactive primitive is built on Radix, so keyboard navigation, focus management, and ARIA are handled for you.