Skip to main content

Collapsible

A disclosure region that expands with an interruptible spring height and a soft blur, wired with the right ARIA attributes.

Release artifacts (3)
registry.json42 KB
collapsible.tsx14 KB
motion-tokens.ts6 KB
Release tag

Customize

Content blur (px)4
Spring speed1

Installation

npx shadcn@latest add @kinetic/collapsible

Usage

Wrap a CollapsibleTrigger and a CollapsibleContent in Collapsible.

import {
  Collapsible,
  CollapsibleContent,
  CollapsibleTrigger,
} from "@/components/kinetic/ui/collapsible";

export function Details() {
  return (
    <Collapsible>
      <CollapsibleTrigger>Show details</CollapsibleTrigger>
      <CollapsibleContent>Extra information goes here.</CollapsibleContent>
    </Collapsible>
  );
}

Controlled state

Use open with onOpenChange, or defaultOpen to start expanded.

const [open, setOpen] = useState(true);

<Collapsible open={open} onOpenChange={setOpen}>...</Collapsible>

Custom trigger

Set asChild on CollapsibleTrigger to pass the toggle and ARIA props to your own button.

<CollapsibleTrigger asChild>
  <Button variant="ghost" size="icon-sm" aria-label="Toggle">
    <ChevronsUpDownIcon />
  </Button>
</CollapsibleTrigger>

Keep mounted

By default the content unmounts when closed. Set keepMounted on Collapsible (or forceMount on the content) to keep it in the DOM with the hidden attribute. Use disabled to lock the toggle.

<Collapsible keepMounted>...</Collapsible>

Motion preferences

Use blurPx and speed to tune the reveal. Reduced motion expands and collapses instantly.

API Reference

Collapsible

Zero-dependency disclosure root managing open state, spring height physics, blur-fade intensity, and keepMounted behavior.

PropTypeDefaultDescription
open / defaultOpen / onOpenChangeboolean / (open: boolean) => void-Controlled or uncontrolled expanded state.
blurPx / speednumber4 / 1Soft blur radius during reveal/collapse (0-16 px) and spring speed multiplier (0.25-4).
keepMounted / disabledbooleanfalse / falseKeeps collapsed children mounted with hidden attribute, or disables toggling.

CollapsibleTrigger / CollapsibleContent

Zero-dep asChild trigger button with aria-expanded/aria-controls and RAF spring-animated content container.

PropTypeDefaultDescription
asChild (Trigger) / forceMount (Content)booleanfalseDelegates trigger ARIA props to a child button; forceMount aliases keepMounted on content.

Notes

Always add aria-label when CollapsibleTrigger wraps an icon-only Button.