Collapsible

Unstyled disclosure primitive (Collapsible, CollapsibleTrigger with asChild, CollapsibleContent) with controlled or uncontrolled open state, an in-flow height morph that fades content in and closes faster than it opens, aria-expanded/aria-controls wiring, an inert closed panel and a reduced-motion snap.

Preview

Collapsible preview width

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @karaui/collapsible
@karaui not found? Add it to components.json
{
  "registries": {
    "@karaui": "https://karaui.kamisama-v0.my.id/r/{name}.json"
  }
}

@karaui is in shadcn's public registry directory, so the latest CLI needs no setup. On an older CLI, merge this into the existing file once and every @karaui/… install resolves.

API Reference

CollapsibleContent

innerClassName?
string

Class for the inner wrapper that holds the children (padding goes here, never on the animated outer element, so the closed height is truly 0).

—
region?
boolean

Set to give the panel `role="region"` labelled by its trigger.

false
className?
string
—

Collapsible

open?
boolean

Controlled open state.

—
defaultOpen?
boolean

Initial open state when uncontrolled.

false
onOpenChange?
((open: boolean) => void)
—
disabled?
boolean
false
triggerId?
string

Override the generated trigger id (the content is labelled by it).

—
contentId?
string

Override the generated content id (the trigger controls it).

—
className?
string
—

CollapsibleTrigger

asChild?
boolean

Merge trigger behaviour onto the single child element instead of rendering a `<button>`.

—
className?
string
—

Updated