{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "accordion-underline",
  "title": "Underline accordion",
  "description": "Styled accordion: the Underline set. 5 decorative accordion variations (SweepAccordion, CenterAccordion, GrowAccordion, DoubleAccordion, DashedAccordion) 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/accordion-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 accordion family: 5 minimal accordions. When a row opens an\n   animated underline sweeps in below the header; the variants change how the\n   line enters and how it looks. Every export is a complete accordion: internal\n   single-open state, a button header with aria-expanded, framer height auto\n   animation. Colour comes ONLY from tokens. Alpha via color-mix. Under\n   reduced-motion the line appears instantly instead of transforming and the\n   panel opens instantly. Size = padding + text scale. Renders without props\n   too. */\n\nexport type StyledSize = \"sm\" | \"md\" | \"lg\" | \"xl\"\n\nexport interface StyledAccordionItem {\n  value: string\n  title: React.ReactNode\n  content: React.ReactNode\n}\n\ninterface StyledAccordionProps {\n  className?: string\n  size?: StyledSize\n  items?: StyledAccordionItem[]\n  defaultOpen?: string\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 text-sm\",\n  md: \"px-1 pb-3 text-sm\",\n  lg: \"px-1 pb-4 text-base\",\n  xl: \"px-1 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 defaultItems: StyledAccordionItem[] = [\n  {\n    value: \"item-1\",\n    title: \"What is included?\",\n    content:\n      \"Every plan ships the full component library, semantic tokens, and lifetime updates for the tier you own.\",\n  },\n  {\n    value: \"item-2\",\n    title: \"How does installation work?\",\n    content:\n      \"Add any component with a single CLI command. Files land in your project and stay fully editable.\",\n  },\n  {\n    value: \"item-3\",\n    title: \"Can I use it in production?\",\n    content:\n      \"Yes. The system is framework agnostic, self contained, and safe to ship to any number of projects.\",\n  },\n]\n\nfunction useSingleOpen(defaultOpen?: string) {\n  const [open, setOpen] = React.useState<string | null>(defaultOpen ?? null)\n  const toggle = React.useCallback(\n    (value: string) => setOpen((cur) => (cur === value ? null : value)),\n    []\n  )\n  return { open, toggle }\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\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\")}>\n            {children}\n          </div>\n        </motion.div>\n      )}\n    </AnimatePresence>\n  )\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={{ rotate: isOpen ? 180 : 0 }}\n      transition={reduce ? { duration: 0 } : { duration: 0.2 }}\n    >\n      <ChevronDown className={iconSize[size]} />\n    </motion.span>\n  )\n}\n\ninterface LineStyle {\n  /* cizginin origin/giris yonu */\n  mode: \"left\" | \"center\" | \"grow\"\n  /* line thickness plus extra styling (e.g. double, dashed) */\n  lineClass: string\n}\n\n/* Shared underline shell: an animated underline below the header. Rows are\n   divided by a token line; the open row gets a primary line sweeping in.\n   lineStyle is each variant. */\nfunction UnderlineShell({\n  props,\n  lineStyle,\n}: {\n  props: StyledAccordionProps\n  lineStyle: LineStyle\n}) {\n  const { className, size = \"md\", items = defaultItems, defaultOpen } = props\n  const { open, toggle } = useSingleOpen(defaultOpen)\n  const reduce = useReducedMotion()\n  return (\n    <div\n      data-slot=\"styled-accordion\"\n      className={cn(\"flex flex-col\", className)}\n    >\n      {items.map((item, i) => {\n        const isOpen = open === item.value\n        const originClass =\n          lineStyle.mode === \"left\"\n            ? \"origin-left\"\n            : lineStyle.mode === \"center\"\n              ? \"origin-center\"\n              : \"origin-left\"\n        return (\n          <div\n            key={item.value}\n            className={cn(i > 0 && \"border-t border-border\")}\n          >\n            <button\n              type=\"button\"\n              aria-expanded={isOpen}\n              onClick={() => toggle(item.value)}\n              className={cn(headerBase, headerPad[size])}\n            >\n              <span className=\"min-w-0\">{item.title}</span>\n              <Chevron isOpen={isOpen} size={size} />\n              <motion.span\n                aria-hidden\n                className={cn(\n                  \"pointer-events-none absolute inset-x-0 bottom-0\",\n                  originClass,\n                  lineStyle.lineClass\n                )}\n                initial={false}\n                animate={\n                  reduce\n                    ? { opacity: isOpen ? 1 : 0 }\n                    : { scaleX: isOpen ? 1 : 0, opacity: isOpen ? 1 : 0 }\n                }\n                transition={\n                  reduce\n                    ? { duration: 0 }\n                    : { duration: 0.28, ease: [0.4, 0, 0.2, 1] }\n                }\n              />\n            </button>\n            <Panel isOpen={isOpen} size={size}>\n              {item.content}\n            </Panel>\n          </div>\n        )\n      })}\n    </div>\n  )\n}\n\n/* Sweep: a single primary line sweeping in from the left. */\nexport function SweepAccordion(props: StyledAccordionProps) {\n  return (\n    <UnderlineShell\n      props={props}\n      lineStyle={{ mode: \"left\", lineClass: \"h-0.5 bg-primary\" }}\n    />\n  )\n}\n\n/* Center: a primary line opening outwards from the centre. */\nexport function CenterAccordion(props: StyledAccordionProps) {\n  return (\n    <UnderlineShell\n      props={props}\n      lineStyle={{ mode: \"center\", lineClass: \"h-0.5 bg-primary\" }}\n    />\n  )\n}\n\n/* Grow: a thicker line growing from the left. */\nexport function GrowAccordion(props: StyledAccordionProps) {\n  return (\n    <UnderlineShell\n      props={props}\n      lineStyle={{ mode: \"grow\", lineClass: \"h-1 rounded-full bg-primary\" }}\n    />\n  )\n}\n\n/* Double: a two-layer double line (primary plus a soft one below). */\nexport function DoubleAccordion(props: StyledAccordionProps) {\n  return (\n    <UnderlineShell\n      props={props}\n      lineStyle={{\n        mode: \"left\",\n        lineClass:\n          \"h-0.5 bg-primary shadow-[0_3px_0_0_color-mix(in_oklab,var(--color-primary)_35%,transparent)]\",\n      }}\n    />\n  )\n}\n\n/* Dashed: a dashed primary underline sweeping in from the left. */\nexport function DashedAccordion(props: StyledAccordionProps) {\n  return (\n    <UnderlineShell\n      props={props}\n      lineStyle={{\n        mode: \"left\",\n        lineClass:\n          \"h-0 border-b-2 border-dashed border-primary\",\n      }}\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/accordion-underline.tsx"
    }
  ],
  "categories": [
    "styled",
    "accordion"
  ],
  "type": "registry:component"
}