{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "accordion",
  "title": "Accordion",
  "description": "An accessible accordion with single or multiple open panels, default, card and filled variants, chevron or plus indicators, smooth height animation and full keyboard navigation.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/accordion/accordion.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface AccordionItem {\n  value: string;\n  title: React.ReactNode;\n  content: React.ReactNode;\n  icon?: React.ReactNode;\n  disabled?: boolean;\n}\n\nexport type AccordionVariant = \"default\" | \"card\" | \"filled\";\nexport type AccordionSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface AccordionProps {\n  items?: AccordionItem[];\n  type?: \"single\" | \"multiple\";\n  value?: string[];\n  defaultValue?: string[];\n  onValueChange?: (value: string[]) => void;\n  collapsible?: boolean;\n  variant?: AccordionVariant;\n  size?: AccordionSize;\n  indicator?: \"chevron\" | \"plus\";\n  theme?: \"dark\" | \"light\";\n  width?: number | string;\n  className?: string;\n}\n\nconst DEFAULT_ITEMS: AccordionItem[] = [\n  { value: \"install\", title: \"How do I install a component?\", content: \"Copy the source into your project or run the shadcn CLI command shown on each component page. There are no runtime dependencies beyond motion, clsx and tailwind-merge.\" },\n  { value: \"customize\", title: \"Can I customize the design?\", content: \"Everything is plain React and Tailwind, so you own the code. Most components also expose props for colors, sizes and behavior.\" },\n  { value: \"license\", title: \"What license do the components use?\", content: \"Free components are MIT licensed. Premium components come with a commercial license for unlimited personal and client projects.\" },\n  { value: \"support\", title: \"Where can I get help?\", content: \"Open an issue on GitHub or reach out through the support page. We usually reply within a day.\" },\n];\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.6)\", line: \"rgba(255,255,255,0.1)\", card: \"#0E0E0E\", filled: \"rgba(255,255,255,0.05)\", hover: \"rgba(255,255,255,0.04)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.6)\", line: \"rgba(10,10,10,0.12)\", card: \"#FFFFFF\", filled: \"rgba(10,10,10,0.04)\", hover: \"rgba(10,10,10,0.03)\" },\n};\n\nconst SIZES: Record<AccordionSize, { title: number; body: number; padX: number; padY: number; icon: number }> = {\n  sm: { title: 14, body: 13, padX: 14, padY: 12, icon: 16 },\n  md: { title: 15.5, body: 14, padX: 18, padY: 16, icon: 18 },\n  lg: { title: 17, body: 15, padX: 22, padY: 20, icon: 20 },\n};\n\nfunction Indicator({ kind, open, size, color }: { kind: \"chevron\" | \"plus\"; open: boolean; size: number; color: string }) {\n  if (kind === \"plus\") {\n    return (\n      <svg width={size} height={size} viewBox=\"0 0 16 16\" fill=\"none\" stroke={color} strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\">\n        <path d=\"M3 8h10\" />\n        <motion.path d=\"M8 3v10\" initial={false} animate={{ scaleY: open ? 0 : 1, opacity: open ? 0 : 1 }} style={{ transformOrigin: \"8px 8px\" }} transition={{ duration: 0.2 }} />\n      </svg>\n    );\n  }\n  return (\n    <motion.svg width={size} height={size} viewBox=\"0 0 16 16\" fill=\"none\" stroke={color} strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" initial={false} animate={{ rotate: open ? 180 : 0 }} transition={{ type: \"spring\", stiffness: 420, damping: 28 }}>\n      <path d=\"M4 6.2L8 10L12 6.2\" />\n    </motion.svg>\n  );\n}\n\nexport function Accordion({ items = DEFAULT_ITEMS, type = \"single\", value, defaultValue, onValueChange, collapsible = true, variant = \"default\", size = \"md\", indicator = \"chevron\", theme = \"dark\", width = 870, className }: AccordionProps) {\n  const p = PALETTES[theme];\n  const s = SIZES[size];\n  const uid = React.useId();\n  const [internal, setInternal] = React.useState<string[]>(defaultValue ?? (items[0] ? [items[0].value] : []));\n  const isControlled = value !== undefined;\n  const openValues = isControlled ? value : internal;\n  const headerRefs = React.useRef<Record<string, HTMLButtonElement | null>>({});\n  const card = variant === \"card\";\n\n  const toggle = (v: string) => {\n    let next: string[];\n    const isOpen = openValues.includes(v);\n    if (type === \"multiple\") next = isOpen ? openValues.filter((x) => x !== v) : [...openValues, v];\n    else next = isOpen ? (collapsible ? [] : [v]) : [v];\n    if (!isControlled) setInternal(next);\n    onValueChange?.(next);\n  };\n\n  const onKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>, v: string) => {\n    const enabled = items.filter((i) => !i.disabled).map((i) => i.value);\n    const idx = enabled.indexOf(v);\n    let target: string | undefined;\n    if (e.key === \"ArrowDown\") target = enabled[(idx + 1) % enabled.length];\n    else if (e.key === \"ArrowUp\") target = enabled[(idx - 1 + enabled.length) % enabled.length];\n    else if (e.key === \"Home\") target = enabled[0];\n    else if (e.key === \"End\") target = enabled[enabled.length - 1];\n    if (!target) return;\n    e.preventDefault();\n    headerRefs.current[target]?.focus();\n  };\n\n  return (\n    <div className={cn(\"flex flex-col\", card && \"gap-2.5\", className)} style={{ width, maxWidth: \"100%\", fontFamily: \"Inter, sans-serif\", color: p.text, ...(variant === \"default\" ? { borderTop: `1px solid ${p.line}` } : {}) }}>\n      {items.map((item) => {\n        const open = openValues.includes(item.value);\n        return (\n          <div\n            key={item.value}\n            style={{\n              borderStyle: \"solid\",\n              borderColor: card && open ? `color-mix(in srgb, ${p.text} 35%, transparent)` : p.line,\n              borderTopWidth: card ? 1 : 0,\n              borderRightWidth: card ? 1 : 0,\n              borderBottomWidth: card || variant === \"default\" ? 1 : 0,\n              borderLeftWidth: card ? 1 : 0,\n              borderRadius: card ? 16 : variant === \"filled\" ? 14 : 0,\n              background: card ? p.card : variant === \"filled\" ? p.filled : \"transparent\",\n              marginBottom: variant === \"filled\" ? 8 : undefined,\n              transition: \"border-color 0.2s ease\",\n              overflow: \"hidden\",\n            }}\n          >\n            <h3 className=\"m-0\">\n              <button\n                ref={(el) => {\n                  headerRefs.current[item.value] = el;\n                }}\n                type=\"button\"\n                id={`${uid}-h-${item.value}`}\n                aria-expanded={open}\n                aria-controls={`${uid}-p-${item.value}`}\n                disabled={item.disabled}\n                onClick={() => toggle(item.value)}\n                onKeyDown={(e) => onKeyDown(e, item.value)}\n                className=\"flex w-full items-center justify-between gap-4 border-none bg-transparent text-left font-semibold tracking-[-0.01em] outline-none focus-visible:ring-2 focus-visible:ring-inset\"\n                style={{ padding: `${s.padY}px ${s.padX}px`, fontSize: s.title, lineHeight: `${Math.round(s.title * 1.4)}px`, color: p.text, cursor: item.disabled ? \"default\" : \"pointer\", opacity: item.disabled ? 0.4 : 1, [\"--tw-ring-color\" as string]: p.text }}\n              >\n                <span className=\"flex items-center gap-3\">\n                  {item.icon && <span className=\"flex shrink-0\" style={{ width: s.icon, height: s.icon, color: open ? p.text : p.muted, transition: \"color 0.2s ease\" }}>{item.icon}</span>}\n                  {item.title}\n                </span>\n                <span className=\"flex shrink-0\">\n                  <Indicator kind={indicator} open={open} size={s.icon} color={open ? p.text : p.muted} />\n                </span>\n              </button>\n            </h3>\n            <AnimatePresence initial={false}>\n              {open && (\n                <motion.div\n                  key=\"panel\"\n                  id={`${uid}-p-${item.value}`}\n                  role=\"region\"\n                  aria-labelledby={`${uid}-h-${item.value}`}\n                  initial={{ height: 0, opacity: 0 }}\n                  animate={{ height: \"auto\", opacity: 1 }}\n                  exit={{ height: 0, opacity: 0 }}\n                  transition={{ height: { duration: 0.28, ease: [0.16, 1, 0.3, 1] }, opacity: { duration: 0.2 } }}\n                  style={{ overflow: \"hidden\" }}\n                >\n                  <div style={{ padding: `0 ${s.padX}px ${s.padY}px`, fontSize: s.body, lineHeight: `${Math.round(s.body * 1.65)}px`, color: p.muted }}>{item.content}</div>\n                </motion.div>\n              )}\n            </AnimatePresence>\n          </div>\n        );\n      })}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}