{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "filter-tabs",
  "type": "registry:component",
  "title": "Filter tabs",
  "description": "Compact filter buttons with selected, count, and disabled states.",
  "categories": [
    "navigation"
  ],
  "dependencies": [],
  "registryDependencies": [
    "button"
  ],
  "files": [
    {
      "path": "src/registry/overtrue/filter-tabs.tsx",
      "type": "registry:component",
      "target": "components/overtrue/filter-tabs.tsx",
      "content": "\"use client\";\nimport {\n  useCallback,\n  useEffect,\n  useLayoutEffect,\n  useRef,\n  useState,\n  type ReactNode,\n} from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface FilterOption<T extends string = string> {\n  value: T;\n  label: ReactNode;\n  count?: number;\n  disabled?: boolean;\n}\n\ninterface IndicatorRect {\n  left: number;\n  top: number;\n  width: number;\n  height: number;\n}\n\nconst useIsoLayoutEffect =\n  typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/** Filters a shared result set; these are pressed buttons, not tab panels. */\nexport function FilterTabs<T extends string>({\n  label,\n  items,\n  value,\n  onValueChange,\n  className,\n}: {\n  label: string;\n  items: readonly FilterOption<T>[];\n  value: T;\n  onValueChange: (value: T) => void;\n  className?: string;\n}) {\n  const root = useRef<HTMLDivElement>(null);\n  const [rect, setRect] = useState<IndicatorRect | null>(null);\n  // The first placement snaps; later changes glide.\n  const [glide, setGlide] = useState(false);\n\n  const measure = useCallback(() => {\n    const pressed = root.current?.querySelector<HTMLElement>(\n      ':scope > [aria-pressed=\"true\"]',\n    );\n    if (!pressed) {\n      setRect(null);\n      return;\n    }\n    const next = {\n      left: pressed.offsetLeft,\n      top: pressed.offsetTop,\n      width: pressed.offsetWidth,\n      height: pressed.offsetHeight,\n    };\n    setRect((current) =>\n      current &&\n      current.left === next.left &&\n      current.top === next.top &&\n      current.width === next.width &&\n      current.height === next.height\n        ? current\n        : next,\n    );\n  }, []);\n\n  useIsoLayoutEffect(measure, [measure, value, items]);\n\n  useEffect(() => {\n    const element = root.current;\n    if (!element) return;\n    const observer = new ResizeObserver(measure);\n    observer.observe(element);\n    for (const child of element.children) observer.observe(child);\n    const frame = requestAnimationFrame(() => setGlide(true));\n    return () => {\n      observer.disconnect();\n      cancelAnimationFrame(frame);\n    };\n  }, [measure, items]);\n\n  return (\n    <div\n      ref={root}\n      data-slot=\"filter-tabs\"\n      data-indicator={rect ? \"\" : undefined}\n      role=\"group\"\n      aria-label={label}\n      className={cn(\n        \"group/filters relative isolate flex flex-wrap items-center gap-1\",\n        className,\n      )}\n    >\n      {rect ? (\n        <span\n          aria-hidden=\"true\"\n          data-slot=\"filter-tabs-indicator\"\n          className={cn(\n            \"pointer-events-none absolute top-0 left-0 -z-10 rounded-lg bg-primary/10 shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--color-primary)_22%,transparent)] dark:bg-primary/15\",\n            glide &&\n              \"transition-[translate,width,height] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none\",\n          )}\n          style={{\n            width: rect.width,\n            height: rect.height,\n            translate: `${rect.left}px ${rect.top}px`,\n          }}\n        />\n      ) : null}\n      {items.map((item) => {\n        const selected = item.value === value;\n        return (\n          <Button\n            key={item.value}\n            type=\"button\"\n            size=\"sm\"\n            variant=\"ghost\"\n            disabled={item.disabled}\n            aria-pressed={selected}\n            onClick={() => onValueChange(item.value)}\n            className={cn(\n              \"h-8 gap-2 rounded-lg border-0 px-3 text-xs font-medium shadow-none transition-[color,background-color,box-shadow] duration-150 focus-visible:ring-2 focus-visible:ring-primary/30 motion-reduce:transition-none\",\n              selected\n                ? \"bg-primary/10 text-primary hover:bg-primary/15 hover:text-primary dark:bg-primary/15 dark:hover:bg-primary/20 group-data-[indicator]/filters:bg-transparent group-data-[indicator]/filters:hover:bg-transparent dark:group-data-[indicator]/filters:bg-transparent dark:group-data-[indicator]/filters:hover:bg-transparent\"\n                : \"text-muted-foreground hover:bg-muted/70 hover:text-foreground dark:hover:bg-muted/50\",\n            )}\n          >\n            {item.label}\n            {item.count !== undefined && (\n              <span\n                data-slot=\"filter-tabs-count\"\n                className={cn(\n                  \"-me-1 min-w-5 rounded-full px-1.5 text-center text-[11px] leading-[18px] font-medium tabular-nums transition-colors duration-150 motion-reduce:transition-none\",\n                  selected\n                    ? \"bg-primary/15 text-primary dark:bg-primary/20\"\n                    : \"bg-muted text-muted-foreground dark:bg-muted/70\",\n                )}\n              >\n                {item.count}\n              </span>\n            )}\n          </Button>\n        );\n      })}\n    </div>\n  );\n}\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/filter-tabs. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
