Collapsible

Free · MIT

shadcn's collapsible (Radix) in Candor's theme.

Markdown

Preview

Install

With the Candor CLI

First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/collapsible

Brings in: render-prop, utils · npm: radix-ui@^1.8.1

Usage

TSX · The example above
"use client"

import { ChevronDown } from "lucide-react"
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"

export default function Example() {
  return (
    <Collapsible className="w-full max-w-sm rounded-lg border">
      <CollapsibleTrigger className="group flex w-full items-center justify-between px-3 py-2 text-sm font-medium">
        Why the agent stopped
        <ChevronDown aria-hidden className="size-4 transition-transform group-data-[state=open]:rotate-180" />
      </CollapsibleTrigger>
      <CollapsibleContent className="border-t px-3 py-2 text-sm text-muted-foreground">The run reached its $5.00 budget before the last step.</CollapsibleContent>
    </Collapsible>
  )
}

<Collapsible>

No props.

Also takes the props of React.ComponentProps<typeof CollapsiblePrimitive.Root>.

<CollapsibleTrigger>

No props.

Also takes the props of React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>RenderProp.

<CollapsibleContent>

The content opens and closes to the height Radix measured (--radix-collapsible-content-height), so a change of state is seen settling rather than snapping; data-motion="none" and the OS's reduced-motion setting make it snap.

No props.

Also takes the props of React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>.