{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sliding-tabs",
  "title": "Sliding tabs",
  "description": "Filter tabs where one white pill glides to the chosen tab. Arrow keys work.",
  "files": [
    {
      "path": "registry/dgit/ui/sliding-tabs.tsx",
      "content": "import { useLayoutEffect, useRef, useState, type KeyboardEvent } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\n/** Sliding tabs: one white pill glides to the chosen tab (measured, then translated). Arrow keys move; scrolls sideways on narrow screens. */\nexport function SlidingTabs<T extends string>({ value, options, onChange, label }: { value: T; options: readonly { value: T; label: string }[]; onChange: (v: T) => void; label: string }) {\n  const refs = useRef<Record<string, HTMLButtonElement | null>>({});\n  const [box, setBox] = useState({ x: 0, w: 0, ready: false });\n  useLayoutEffect(() => {\n    const measure = () => {\n      const el = refs.current[value]; if (!el) return;\n      setBox({ x: el.offsetLeft, w: el.offsetWidth, ready: true });\n    };\n    measure();\n    window.addEventListener(\"resize\", measure);\n    document.fonts?.ready.then(measure);\n    return () => window.removeEventListener(\"resize\", measure);\n  }, [value, options]);\n  const onKey = (e: KeyboardEvent) => {\n    const i = options.findIndex((o) => o.value === value);\n    const n = e.key === \"ArrowRight\" ? i + 1 : e.key === \"ArrowLeft\" ? i - 1 : i;\n    if (n !== i && options[n]) { e.preventDefault(); onChange(options[n].value); refs.current[options[n].value]?.focus(); }\n  };\n  return (\n    <div className=\"max-w-full overflow-x-auto\">\n      <div role=\"tablist\" aria-label={label} onKeyDown={onKey} className=\"relative inline-flex rounded-full bg-gray-200 p-1\">\n        <span aria-hidden className={cn(\"shadow-card absolute top-1 bottom-1 rounded-full bg-background-100\", box.ready && \"transition-[transform,width] duration-300 ease-out\")} style={{ width: box.w, transform: `translateX(${box.x}px)` }} />\n        {options.map((o) => (\n          <button key={o.value} ref={(el) => { refs.current[o.value] = el; }} type=\"button\" role=\"tab\" aria-selected={value === o.value} tabIndex={value === o.value ? 0 : -1} onClick={() => onChange(o.value)}\n            className={cn(\"relative z-10 whitespace-nowrap rounded-full px-5 py-2 text-heading-16 transition-colors duration-150\", value === o.value ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\")}>{o.label}</button>\n        ))}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}