{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"shadcn-studio/combobox-12","type":"registry:component","title":"Combobox 12","description":"Multi-select combobox with a count badge showing the number of selected frameworks.","dependencies":["lucide-react"],"registryDependencies":["badge","combobox","label"],"files":[{"path":"src/registry/new-york/components/combobox/combobox-12.tsx","content":"'use client'\n\nimport { useId, useRef, useState } from 'react'\n\nimport { Badge } from '@/registry/new-york/ui/badge'\nimport {\n  Combobox,\n  ComboboxChips,\n  ComboboxChipsInput,\n  ComboboxContent,\n  ComboboxEmpty,\n  ComboboxItem,\n  ComboboxList,\n  ComboboxValue,\n  useComboboxAnchor\n} from '@/registry/new-york/ui/combobox'\nimport { Label } from '@/registry/new-york/ui/label'\n\nconst frameworks = ['Next.js', 'SvelteKit', 'Nuxt.js', 'Remix', 'Astro', 'React', 'Vue', 'Angular', 'SolidJS', 'Qwik']\n\nconst ComboboxMultipleCountBadgeDemo = () => {\n  const id = useId()\n  const anchor = useComboboxAnchor()\n  const [open, setOpen] = useState(false)\n  const inputRef = useRef<HTMLInputElement>(null)\n\n  return (\n    <div className='w-full max-w-xs space-y-2'>\n      <Label htmlFor={id}>Multiple Count badge</Label>\n      <Combobox\n        multiple\n        autoHighlight\n        id={id}\n        items={frameworks}\n        defaultValue={[frameworks[0], frameworks[1], frameworks[2], frameworks[3], frameworks[4], frameworks[5]]}\n        open={open}\n        onOpenChange={setOpen}\n      >\n        <ComboboxChips\n          ref={anchor}\n          onClick={() => {\n            setOpen(true)\n            inputRef.current?.focus()\n          }}\n        >\n          <ComboboxValue>\n            {(values: string[]) =>\n              values.length > 0 ? (\n                <>\n                  <Badge variant='secondary' className='rounded-md'>\n                    {values.length}\n                  </Badge>\n                  <span className='text-sm'>frameworks selected</span>\n                  <ComboboxChipsInput ref={inputRef} />\n                </>\n              ) : (\n                <ComboboxChipsInput ref={inputRef} />\n              )\n            }\n          </ComboboxValue>\n        </ComboboxChips>\n        <ComboboxContent anchor={anchor}>\n          <ComboboxEmpty>No items found.</ComboboxEmpty>\n          <ComboboxList>\n            {item => (\n              <ComboboxItem key={item} value={item}>\n                {item}\n              </ComboboxItem>\n            )}\n          </ComboboxList>\n        </ComboboxContent>\n      </Combobox>\n    </div>\n  )\n}\n\nexport default ComboboxMultipleCountBadgeDemo\n","type":"registry:component","target":"components/shadcn-studio/combobox/combobox-12.tsx"}]}