{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "collapsible-split",
  "title": "Split collapsible",
  "description": "Styled collapsible: the Split set. 5 decorative collapsible variations (PillCollapsible, SquareCollapsible, GhostCollapsible, OutlineCollapsible, FilledCollapsible) on the ai2 token system, powered by framer-motion, reduced-motion aware and sized sm to xl. Part of the free styled layer.",
  "dependencies": [
    "motion@^12.42.2",
    "lucide-react@^1.23.0"
  ],
  "registryDependencies": [
    "@ai2/tokens"
  ],
  "files": [
    {
      "path": "registry/ai2/styled/collapsible-split.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ChevronDown } from \"lucide-react\"\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/* Split collapsible family: 5 collapsibles with the title on the left and the\n   chevron on the right inside a pill/badge. Each export is a complete\n   collapsible: a single trigger + a single expanding body, a button with\n   aria-expanded, and a framer height auto animation. Works controlled\n   (open/onOpenChange) and uncontrolled (defaultOpen). The difference is on the\n   right-hand BADGE: its shape and fill change (Pill, Square, Ghost, Outline,\n   Filled). Color comes ONLY from tokens. Alpha via color-mix. No transform under\n   reduced-motion. Size = padding + text scale. */\n\nexport type StyledSize = \"sm\" | \"md\" | \"lg\" | \"xl\"\n\ninterface StyledCollapsibleProps {\n  className?: string\n  size?: StyledSize\n  title?: React.ReactNode\n  children?: React.ReactNode\n  open?: boolean\n  defaultOpen?: boolean\n  onOpenChange?: (o: boolean) => void\n}\n\nconst headerPad: Record<StyledSize, string> = {\n  sm: \"px-3 py-2.5 text-sm\",\n  md: \"px-4 py-3 text-sm\",\n  lg: \"px-5 py-4 text-base\",\n  xl: \"px-6 py-5 text-lg\",\n}\n\nconst bodyPad: Record<StyledSize, string> = {\n  sm: \"px-3 pb-2.5 text-sm\",\n  md: \"px-4 pb-3 text-sm\",\n  lg: \"px-5 pb-4 text-base\",\n  xl: \"px-6 pb-5 text-base\",\n}\n\nconst iconSize: Record<StyledSize, string> = {\n  sm: \"size-4\",\n  md: \"size-4\",\n  lg: \"size-5\",\n  xl: \"size-5\",\n}\n\nconst badgeSize: Record<StyledSize, string> = {\n  sm: \"size-6\",\n  md: \"size-7\",\n  lg: \"size-8\",\n  xl: \"size-9\",\n}\n\nconst headerBase =\n  \"flex w-full items-center justify-between gap-3 text-left font-medium outline-none transition-colors focus-visible:ring-[3px] focus-visible:ring-ring/50\"\n\nconst defaultTitle = \"What is included?\"\n\nconst defaultChildren =\n  \"Every plan ships the full component library, semantic tokens, and lifetime updates for the tier you own. Add any component with a single CLI command and keep the files fully editable.\"\n\n/* Controlled and uncontrolled open state in a single hook. */\nfunction useControllableOpen({\n  open,\n  defaultOpen,\n  onOpenChange,\n}: {\n  open?: boolean\n  defaultOpen?: boolean\n  onOpenChange?: (o: boolean) => void\n}) {\n  const isControlled = open !== undefined\n  const [internal, setInternal] = React.useState<boolean>(defaultOpen ?? false)\n  const current = isControlled ? (open as boolean) : internal\n  const toggle = React.useCallback(() => {\n    const next = !current\n    if (!isControlled) setInternal(next)\n    onOpenChange?.(next)\n  }, [current, isControlled, onOpenChange])\n  return { isOpen: current, toggle }\n}\n\nfunction Panel({\n  isOpen,\n  size,\n  children,\n}: {\n  isOpen: boolean\n  size: StyledSize\n  children: React.ReactNode\n}) {\n  const reduce = useReducedMotion()\n  return (\n    <AnimatePresence initial={false}>\n      {isOpen && (\n        <motion.div\n          key=\"panel\"\n          initial={reduce ? false : { height: 0, opacity: 0 }}\n          animate={{ height: \"auto\", opacity: 1 }}\n          exit={{ height: 0, opacity: 0 }}\n          transition={\n            reduce ? { duration: 0 } : { duration: 0.25, ease: [0.4, 0, 0.2, 1] }\n          }\n          className=\"overflow-hidden\"\n        >\n          <div className={cn(bodyPad[size], \"text-muted-foreground\")}>{children}</div>\n        </motion.div>\n      )}\n    </AnimatePresence>\n  )\n}\n\n/* Shared shell: the title on the left, a badge carrying a chevron on the right. badgeClass carries each variant's shape and fill technique. */\nfunction SplitShell({\n  props,\n  badge,\n  chevronColor,\n}: {\n  props: StyledCollapsibleProps\n  badge: string\n  chevronColor: string\n}) {\n  const { className, size = \"md\", title = defaultTitle, children = defaultChildren } = props\n  const { isOpen, toggle } = useControllableOpen(props)\n  const reduce = useReducedMotion()\n  return (\n    <div\n      data-slot=\"styled-collapsible\"\n      className={cn(\n        \"overflow-hidden rounded-xl border border-border bg-background\",\n        className\n      )}\n    >\n      <button\n        type=\"button\"\n        aria-expanded={isOpen}\n        onClick={toggle}\n        className={cn(\n          headerBase,\n          headerPad[size],\n          \"hover:bg-[color-mix(in_oklab,var(--color-foreground)_4%,transparent)]\"\n        )}\n      >\n        <span className=\"min-w-0 flex-1 truncate\">{title}</span>\n        <span\n          aria-hidden\n          className={cn(\n            \"inline-flex shrink-0 items-center justify-center transition-colors\",\n            badgeSize[size],\n            badge\n          )}\n        >\n          <motion.span\n            className={cn(\"inline-flex\", chevronColor)}\n            animate={reduce ? undefined : { rotate: isOpen ? 180 : 0 }}\n            transition={reduce ? { duration: 0 } : { type: \"spring\" as const, stiffness: 300, damping: 24 }}\n          >\n            <ChevronDown className={iconSize[size]} />\n          </motion.span>\n        </span>\n      </button>\n      <Panel isOpen={isOpen} size={size}>\n        {children}\n      </Panel>\n    </div>\n  )\n}\n\n/* Pill: tam yuvarlak yumusak yuzey. */\nexport function PillCollapsible(props: StyledCollapsibleProps) {\n  return (\n    <SplitShell\n      props={props}\n      badge=\"rounded-full bg-[color-mix(in_oklab,var(--color-foreground)_8%,transparent)]\"\n      chevronColor=\"text-foreground\"\n    />\n  )\n}\n\n/* Square: yumusak koseli kare yuzey. */\nexport function SquareCollapsible(props: StyledCollapsibleProps) {\n  return (\n    <SplitShell\n      props={props}\n      badge=\"rounded-md bg-[color-mix(in_oklab,var(--color-foreground)_8%,transparent)]\"\n      chevronColor=\"text-foreground\"\n    />\n  )\n}\n\n/* Ghost: no surface, only a chevron; a muted tone. */\nexport function GhostCollapsible(props: StyledCollapsibleProps) {\n  return (\n    <SplitShell props={props} badge=\"rounded-full\" chevronColor=\"text-muted-foreground\" />\n  )\n}\n\n/* Outline: seffaf, ince kenarli pill. */\nexport function OutlineCollapsible(props: StyledCollapsibleProps) {\n  return (\n    <SplitShell\n      props={props}\n      badge=\"rounded-full border border-border\"\n      chevronColor=\"text-foreground\"\n    />\n  )\n}\n\n/* Filled: dolu primary pill, primary-foreground chevron. */\nexport function FilledCollapsible(props: StyledCollapsibleProps) {\n  return (\n    <SplitShell\n      props={props}\n      badge=\"rounded-full bg-primary\"\n      chevronColor=\"text-primary-foreground\"\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/collapsible-split.tsx"
    }
  ],
  "categories": [
    "styled",
    "collapsible"
  ],
  "type": "registry:component"
}