{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "category-chips-filter",
  "title": "Category Chips Filter",
  "description": "Use this when a list is filtered by one category at a time: a free-scroll row of chips with a pressed state, the chosen chip scrolled into view and a polite \"12 results\" message.",
  "registryDependencies": [
    "@tealmac/carousel-free-scroll"
  ],
  "files": [
    {
      "path": "registry/patterns/category-chips-filter/category-chips-filter.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { CarouselFreeScroll } from \"@/components/ui/carousel-free-scroll\"\nimport type { CarouselApi } from \"@/components/ui/carousel-kit\"\n\nexport interface Category {\n  id: string\n  label: string\n  count: number\n}\n\nexport interface CategoryChipsFilterProps {\n  categories: Category[]\n  label: string\n  defaultId?: string\n  onChange?: (category: Category) => void\n  className?: string\n}\n\nexport function CategoryChipsFilter({\n  categories,\n  label,\n  defaultId,\n  onChange,\n  className,\n}: CategoryChipsFilterProps) {\n  const [id, setId] = React.useState(defaultId ?? categories[0]?.id)\n  const api = React.useRef<CarouselApi | null>(null)\n  const current = categories.find((category) => category.id === id)\n\n  return (\n    <div className={cn(\"grid gap-2\", className)}>\n      <div role=\"group\" aria-label={label}>\n        <CarouselFreeScroll\n          label={`${label}, scrollable`}\n          setApi={(instance) => {\n            api.current = instance\n          }}\n          slideClassName=\"basis-auto\"\n          items={categories.map((category, index) => ({\n            id: category.id,\n            label: category.label,\n            content: (\n              <button\n                type=\"button\"\n                aria-pressed={category.id === id}\n                onClick={() => {\n                  setId(category.id)\n                  api.current?.scrollTo(index)\n                  onChange?.(category)\n                }}\n                className=\"hover:bg-accent focus-visible:ring-ring/50 aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-primary-foreground inline-flex h-9 items-center gap-1.5 rounded-full border px-4 text-sm whitespace-nowrap transition-colors focus-visible:ring-[3px] focus-visible:outline-none\"\n              >\n                {category.label}\n              </button>\n            ),\n          }))}\n        />\n      </div>\n      <p role=\"status\" className=\"text-muted-foreground text-sm\">\n        {current\n          ? `${current.count} ${current.count === 1 ? \"result\" : \"results\"} in ${current.label}`\n          : \"\"}\n      </p>\n    </div>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}