{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "collapsible-underline",
  "title": "Underline collapsible",
  "description": "Styled collapsible: the Underline set. 5 decorative collapsible variations (SweepCollapsible, CenterCollapsible, GrowCollapsible, DoubleCollapsible, DashedCollapsible) 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-underline.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/* Underline collapsible family: 5 minimal collapsibles with an animated underline\n   that glides beneath the trigger while open. 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   UNDERLINE: how it appears changes (Sweep, Center, Grow, Double, Dashed). Color\n   comes ONLY from tokens. Alpha via color-mix. No transform under reduced-motion.\n   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-1 py-2.5 text-sm\",\n  md: \"px-1 py-3 text-sm\",\n  lg: \"px-1 py-4 text-base\",\n  xl: \"px-1 py-5 text-lg\",\n}\n\nconst bodyPad: Record<StyledSize, string> = {\n  sm: \"px-1 pb-2.5 pt-2 text-sm\",\n  md: \"px-1 pb-3 pt-2 text-sm\",\n  lg: \"px-1 pb-4 pt-3 text-base\",\n  xl: \"px-1 pb-5 pt-3 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 headerBase =\n  \"relative 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 Chevron({ isOpen, size }: { isOpen: boolean; size: StyledSize }) {\n  const reduce = useReducedMotion()\n  return (\n    <motion.span\n      aria-hidden\n      className=\"shrink-0 text-muted-foreground\"\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  )\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: a minimal trigger with a static track underneath and a primary line sweeping in when open. lineClass and origin carry each variant's animation technique. */\nfunction UnderlineShell({\n  props,\n  origin,\n  lineClass,\n  secondLine,\n  grow,\n}: {\n  props: StyledCollapsibleProps\n  origin: string\n  lineClass: string\n  secondLine?: boolean\n  grow?: boolean\n}) {\n  const { className, size = \"md\", title = defaultTitle, children = defaultChildren } = props\n  const { isOpen, toggle } = useControllableOpen(props)\n  const reduce = useReducedMotion()\n  const target = reduce\n    ? { scaleX: isOpen ? 1 : 0, opacity: isOpen ? 1 : 0 }\n    : grow\n      ? { scaleX: isOpen ? 1 : 0, scaleY: isOpen ? 1 : 0.4, opacity: isOpen ? 1 : 0 }\n      : { scaleX: isOpen ? 1 : 0, opacity: isOpen ? 1 : 0 }\n  return (\n    <div data-slot=\"styled-collapsible\" className={cn(\"flex flex-col\", className)}>\n      <button\n        type=\"button\"\n        aria-expanded={isOpen}\n        onClick={toggle}\n        className={cn(headerBase, headerPad[size])}\n      >\n        {title}\n        <Chevron isOpen={isOpen} size={size} />\n        <span\n          aria-hidden\n          className=\"pointer-events-none absolute inset-x-0 bottom-0 h-px bg-[color-mix(in_oklab,var(--color-foreground)_14%,transparent)]\"\n        />\n        <motion.span\n          aria-hidden\n          className={cn(\"pointer-events-none absolute inset-x-0 bottom-0\", origin, lineClass)}\n          initial={false}\n          animate={target}\n          transition={reduce ? { duration: 0 } : { type: \"spring\" as const, stiffness: 240, damping: 28 }}\n        />\n        {secondLine ? (\n          <motion.span\n            aria-hidden\n            className={cn(\n              \"pointer-events-none absolute inset-x-0 bottom-1 h-px\",\n              origin,\n              \"bg-[color-mix(in_oklab,var(--color-primary)_45%,transparent)]\"\n            )}\n            initial={false}\n            animate={{ scaleX: isOpen ? 1 : 0, opacity: isOpen ? 1 : 0 }}\n            transition={reduce ? { duration: 0 } : { type: \"spring\" as const, stiffness: 240, damping: 28 }}\n          />\n        ) : null}\n      </button>\n      <Panel isOpen={isOpen} size={size}>\n        {children}\n      </Panel>\n    </div>\n  )\n}\n\n/* Sweep: a primary line sweeping in from the left. */\nexport function SweepCollapsible(props: StyledCollapsibleProps) {\n  return (\n    <UnderlineShell props={props} origin=\"origin-left\" lineClass=\"h-0.5 bg-primary\" />\n  )\n}\n\n/* Center: a line opening outwards from the centre. */\nexport function CenterCollapsible(props: StyledCollapsibleProps) {\n  return (\n    <UnderlineShell props={props} origin=\"origin-center\" lineClass=\"h-0.5 bg-primary\" />\n  )\n}\n\n/* Grow: a line thickening as it opens from the left. */\nexport function GrowCollapsible(props: StyledCollapsibleProps) {\n  return (\n    <UnderlineShell props={props} origin=\"origin-left\" lineClass=\"h-1 rounded-full bg-primary\" grow />\n  )\n}\n\n/* Double: a two-layer double line. */\nexport function DoubleCollapsible(props: StyledCollapsibleProps) {\n  return (\n    <UnderlineShell props={props} origin=\"origin-left\" lineClass=\"h-0.5 bg-primary\" secondLine />\n  )\n}\n\n/* Dashed: a dashed primary line. */\nexport function DashedCollapsible(props: StyledCollapsibleProps) {\n  return (\n    <UnderlineShell\n      props={props}\n      origin=\"origin-left\"\n      lineClass=\"h-0 border-b-2 border-dashed border-primary\"\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/collapsible-underline.tsx"
    }
  ],
  "categories": [
    "styled",
    "collapsible"
  ],
  "type": "registry:component"
}