{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "animated-tabs",
  "type": "registry:ui",
  "title": "Animated Tabs",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Smooth shared-element sliding pill tabs with animated panel transitions, optional badge counters, and keyboard arrow navigation.",
  "dependencies": [
    "framer-motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/animated-tabs.tsx",
      "content": "\"use client\";\n\nimport React, { useState, useId, useRef } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface TabItem {\n  id: string;\n  label: string;\n  badge?: string | number;\n  content: React.ReactNode;\n}\n\nexport interface AnimatedTabsProps {\n  /** Array of tab definitions */\n  tabs?: TabItem[];\n  /** Default active tab ID */\n  defaultTabId?: string;\n  /** Callback fired when active tab changes */\n  onChange?: (tabId: string) => void;\n  /** Additional container class names */\n  className?: string;\n}\n\nconst DEFAULT_TABS: TabItem[] = [\n  {\n    id: \"preview\",\n    label: \"Overview\",\n    content: (\n      <div className=\"space-y-1.5\">\n        <div className=\"text-xs font-semibold text-black dark:text-white\">\n          Shared-Element Sliding Indicator\n        </div>\n        <p className=\"text-xs leading-relaxed text-neutral-500 dark:text-neutral-400\">\n          The active pill glides smoothly between tabs using Framer Motion\n          layoutId springs with zero layout shift.\n        </p>\n      </div>\n    ),\n  },\n  {\n    id: \"metrics\",\n    label: \"Metrics\",\n    badge: \"99.9%\",\n    content: (\n      <div className=\"grid grid-cols-2 gap-3\">\n        <div className=\"rounded-xl border border-neutral-200 p-3 dark:border-[#222222]\">\n          <div className=\"font-mono text-[10px] text-neutral-400\">FRAME BUDGET</div>\n          <div className=\"mt-1 font-mono text-sm font-semibold text-black dark:text-white\">\n            &lt; 1.2ms\n          </div>\n        </div>\n        <div className=\"rounded-xl border border-neutral-200 p-3 dark:border-[#222222]\">\n          <div className=\"font-mono text-[10px] text-neutral-400\">BUNDLE SIZE</div>\n          <div className=\"mt-1 font-mono text-sm font-semibold text-black dark:text-white\">\n            1.8 kB\n          </div>\n        </div>\n      </div>\n    ),\n  },\n  {\n    id: \"settings\",\n    label: \"Settings\",\n    content: (\n      <div className=\"space-y-1.5\">\n        <div className=\"text-xs font-semibold text-black dark:text-white\">\n          Keyboard Accessible\n        </div>\n        <p className=\"text-xs leading-relaxed text-neutral-500 dark:text-neutral-400\">\n          Use Left, Right, Home, and End keys to cycle through tabs with full\n          WAI-ARIA tablist focus management.\n        </p>\n      </div>\n    ),\n  },\n];\n\nexport function AnimatedTabs({\n  tabs = DEFAULT_TABS,\n  defaultTabId,\n  onChange,\n  className,\n}: AnimatedTabsProps) {\n  const shouldReduceMotion = useReducedMotion();\n  const instanceId = useId();\n  const tabRefs = useRef<Array<HTMLButtonElement | null>>([]);\n  const [activeId, setActiveId] = useState<string>(\n    defaultTabId || tabs[0]?.id || \"\"\n  );\n\n  const activeTab = tabs.find((t) => t.id === activeId) || tabs[0];\n\n  const handleSelect = (id: string, focusIndex?: number) => {\n    setActiveId(id);\n    onChange?.(id);\n    if (focusIndex !== undefined) {\n      tabRefs.current[focusIndex]?.focus();\n    }\n  };\n\n  const handleKeyDown = (\n    e: React.KeyboardEvent<HTMLButtonElement>,\n    idx: number\n  ) => {\n    if (e.key === \"ArrowRight\") {\n      e.preventDefault();\n      const nextIdx = (idx + 1) % tabs.length;\n      const next = tabs[nextIdx];\n      if (next) handleSelect(next.id, nextIdx);\n    } else if (e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      const prevIdx = (idx - 1 + tabs.length) % tabs.length;\n      const prev = tabs[prevIdx];\n      if (prev) handleSelect(prev.id, prevIdx);\n    } else if (e.key === \"Home\") {\n      e.preventDefault();\n      if (tabs[0]) handleSelect(tabs[0].id, 0);\n    } else if (e.key === \"End\") {\n      e.preventDefault();\n      const lastIdx = tabs.length - 1;\n      if (tabs[lastIdx]) handleSelect(tabs[lastIdx].id, lastIdx);\n    }\n  };\n\n  return (\n    <div className={cn(\"w-full max-w-md\", className)}>\n      {/* Tab List */}\n      <div\n        role=\"tablist\"\n        aria-label=\"Content tabs\"\n        className=\"inline-flex w-full items-center gap-1 rounded-xl border border-neutral-200 bg-neutral-100/80 p-1 dark:border-[#222222] dark:bg-[#0C0C0C]\"\n      >\n        {tabs.map((tab, idx) => {\n          const isActive = tab.id === activeId;\n          return (\n            <button\n              key={tab.id}\n              ref={(el) => {\n                tabRefs.current[idx] = el;\n              }}\n              type=\"button\"\n              role=\"tab\"\n              tabIndex={isActive ? 0 : -1}\n              aria-selected={isActive}\n              onClick={() => handleSelect(tab.id)}\n              onKeyDown={(e) => handleKeyDown(e, idx)}\n              className={cn(\n                \"relative flex flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black dark:focus-visible:ring-white\",\n                isActive\n                  ? \"text-white dark:text-black\"\n                  : \"text-neutral-600 hover:text-black dark:text-neutral-400 dark:hover:text-white\"\n              )}\n            >\n              {isActive && (\n                <motion.span\n                  layoutId={`tab-pill-${instanceId}`}\n                  transition={\n                    shouldReduceMotion\n                      ? { duration: 0 }\n                      : { type: \"spring\", stiffness: 420, damping: 32 }\n                  }\n                  className=\"absolute inset-0 rounded-lg bg-black shadow-xs dark:bg-white\"\n                />\n              )}\n              <span className=\"relative z-10\">{tab.label}</span>\n              {tab.badge !== undefined && (\n                <span\n                  className={cn(\n                    \"relative z-10 rounded px-1 py-0.2 font-mono text-[10px]\",\n                    isActive\n                      ? \"bg-white/20 text-white dark:bg-black/15 dark:text-black\"\n                      : \"bg-neutral-200/80 text-neutral-600 dark:bg-[#1A1A1A] dark:text-neutral-400\"\n                  )}\n                >\n                  {tab.badge}\n                </span>\n              )}\n            </button>\n          );\n        })}\n      </div>\n\n      {/* Tab Panel */}\n      <div\n        role=\"tabpanel\"\n        className=\"mt-3 overflow-hidden rounded-2xl border border-neutral-200 bg-white p-5 dark:border-[#222222] dark:bg-[#0A0A0A]\"\n      >\n        <AnimatePresence mode=\"wait\" initial={false}>\n          <motion.div\n            key={activeTab?.id}\n            initial={shouldReduceMotion ? { opacity: 0 } : { opacity: 0, y: 6 }}\n            animate={shouldReduceMotion ? { opacity: 1 } : { opacity: 1, y: 0 }}\n            exit={shouldReduceMotion ? { opacity: 0 } : { opacity: 0, y: -4 }}\n            transition={{ duration: shouldReduceMotion ? 0 : 0.16 }}\n          >\n            {activeTab?.content}\n          </motion.div>\n        </AnimatePresence>\n      </div>\n    </div>\n  );\n}\n\nexport default AnimatedTabs;\n",
      "type": "registry:ui",
      "target": "components/ui/animated-tabs.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
