{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "collapsible", "title": "Collapsible", "description": "Single expandable content section that toggles between collapsed and expanded states.", "dependencies": [ "@base-ui/react" ], "files": [ { "path": "packages/ui/src/collapsible.tsx", "content": "\"use client\";\n\nimport { Collapsible as CollapsiblePrimitive } from \"@base-ui/react/collapsible\";\nimport type * as React from \"react\";\n\nimport { cn } from \"./utils\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype RenderProp =\n | React.ReactElement\n | ((props: any, state: any) => React.ReactElement);\ntype ClassNameProp = string | ((state: any) => string);\n\ntype CollapsibleRootBaseProps = Omit<\n React.ComponentPropsWithoutRef,\n \"className\" | \"render\"\n>;\n\ntype CollapsibleTriggerBaseProps = Omit<\n React.ComponentPropsWithoutRef,\n \"className\" | \"render\"\n>;\n\ntype CollapsiblePanelBaseProps = Omit<\n React.ComponentPropsWithoutRef,\n \"className\" | \"render\" | \"keepMounted\" | \"hiddenUntilFound\"\n>;\n\nexport type CollapsibleProps = CollapsibleRootBaseProps & {\n /** Optional class name or function that returns a class name */\n className?: ClassNameProp;\n /** Optional render function */\n render?: RenderProp;\n};\n\nexport type CollapsibleTriggerProps = CollapsibleTriggerBaseProps & {\n /** Optional class name or function that returns a class name */\n className?: ClassNameProp;\n /** Optional render function */\n render?: RenderProp;\n};\n\nexport type CollapsibleContentProps = CollapsiblePanelBaseProps & {\n /** Whether to keep the panel mounted when closed @default false */\n keepMounted?: boolean;\n /** Whether to use hidden=\"until-found\" for browser search @default false */\n hiddenUntilFound?: boolean;\n /** Optional class name or function that returns a class name */\n className?: ClassNameProp;\n /** Optional render function */\n render?: RenderProp;\n};\n\n// ---------------------------------------------------------------------------\n// Collapsible (root)\n// ---------------------------------------------------------------------------\n\nconst Collapsible = ({\n className,\n ref,\n ...props\n}: CollapsibleProps &\n React.RefAttributes<\n React.ComponentRef\n >) => (\n \n);\n\nCollapsible.displayName = \"Collapsible\";\n\n// ---------------------------------------------------------------------------\n// CollapsibleTrigger\n// ---------------------------------------------------------------------------\n\nconst CollapsibleTrigger = ({\n className,\n ref,\n ...props\n}: CollapsibleTriggerProps &\n React.RefAttributes<\n React.ComponentRef\n >) => (\n \n);\n\nCollapsibleTrigger.displayName = \"CollapsibleTrigger\";\n\n// ---------------------------------------------------------------------------\n// CollapsibleContent\n// ---------------------------------------------------------------------------\n\nconst CollapsibleContent = ({\n className,\n ref,\n ...props\n}: CollapsibleContentProps &\n React.RefAttributes<\n React.ComponentRef\n >) => {\n const baseClasses = cn(\n \"overflow-hidden\",\n // CSS transition on height — smoothly cancellable mid-animation.\n // Reduced motion is handled globally by base.css.\n \"h-[var(--collapsible-panel-height)] transition-[height] duration-200 ease-out\",\n // Enter: start from 0 height\n \"data-[starting-style]:h-0\",\n // Exit: collapse to 0 height\n \"data-[ending-style]:h-0\"\n );\n\n return (\n \n );\n};\n\nCollapsibleContent.displayName = \"CollapsibleContent\";\n\n// ---------------------------------------------------------------------------\n// Exports\n// ---------------------------------------------------------------------------\n\nexport { Collapsible, CollapsibleContent, CollapsibleTrigger };\n", "type": "registry:ui" } ], "type": "registry:ui" }