{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "combobox",
"title": "Combobox",
"description": "Searchable dropdown with autocomplete for filtering and selecting from a list of options.",
"dependencies": [
"@base-ui/react",
"lucide-react"
],
"registryDependencies": [
"button",
"input-group"
],
"files": [
{
"path": "packages/ui/src/combobox.tsx",
"content": "\"use client\";\n\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react/combobox\";\nimport {\n Check as CheckIcon,\n ChevronDown as ChevronDownIcon,\n X as XIcon,\n} from \"lucide-react\";\nimport * as React from \"react\";\nimport { Button } from \"./button\";\nimport {\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupInput,\n} from \"./input-group\";\nimport { cn, POPUP_ITEM_HEIGHT } from \"./utils\";\n\n// =============================================================================\n// Combobox (Root)\n// =============================================================================\nconst Combobox = ComboboxPrimitive.Root;\n\n// =============================================================================\n// ComboboxValue\n// =============================================================================\nexport interface ComboboxValueProps extends ComboboxPrimitive.Value.Props {}\n\nfunction ComboboxValue({ ...props }: ComboboxValueProps) {\n return ;\n}\n\n// =============================================================================\n// ComboboxTrigger\n// =============================================================================\nexport interface ComboboxTriggerProps extends ComboboxPrimitive.Trigger.Props {}\n\nfunction ComboboxTrigger({\n className,\n children,\n ...props\n}: ComboboxTriggerProps) {\n return (\n \n {children}\n \n \n );\n}\n\n// =============================================================================\n// ComboboxClear\n// =============================================================================\nexport interface ComboboxClearProps extends ComboboxPrimitive.Clear.Props {}\n\nfunction ComboboxClear({ className, ...props }: ComboboxClearProps) {\n return (\n }\n {...props}\n >\n \n \n );\n}\n\n// =============================================================================\n// ComboboxInput\n// =============================================================================\nexport interface ComboboxInputProps extends ComboboxPrimitive.Input.Props {\n /**\n * Children to render inside the input group (e.g., InputGroupAddon)\n */\n children?: React.ReactNode;\n /**\n * Show the clear button when a value is selected\n * @default false\n */\n showClear?: boolean;\n /**\n * Show the dropdown trigger button\n * @default true\n */\n showTrigger?: boolean;\n}\n\nfunction ComboboxInput({\n className,\n children,\n disabled = false,\n showTrigger = true,\n showClear = false,\n ...props\n}: ComboboxInputProps) {\n return (\n \n }\n {...props}\n />\n \n {showTrigger && (\n }\n size=\"icon-xs\"\n variant=\"ghost\"\n />\n )}\n {showClear && }\n \n {children}\n \n );\n}\n\n// =============================================================================\n// ComboboxContent\n// =============================================================================\nexport interface ComboboxContentProps extends ComboboxPrimitive.Popup.Props {\n /**\n * Alignment of the content\n * @default \"start\"\n */\n align?: \"start\" | \"center\" | \"end\";\n /**\n * Offset along the alignment axis\n * @default 0\n */\n alignOffset?: number;\n /**\n * Custom anchor element (used for chips mode)\n */\n anchor?: React.RefObject;\n /**\n * Side of the trigger to position the popup\n * @default \"bottom\"\n */\n side?: \"top\" | \"bottom\" | \"left\" | \"right\" | \"inline-start\" | \"inline-end\";\n /**\n * Offset from the trigger\n * @default 6\n */\n sideOffset?: number;\n /**\n * Size of the menu items\n * @default \"default\"\n */\n size?: \"default\" | \"compact\";\n}\n\nfunction ComboboxContent({\n className,\n children,\n side = \"bottom\",\n sideOffset = 6,\n align = \"start\",\n alignOffset = 0,\n anchor,\n size = \"default\",\n ...props\n}: ComboboxContentProps) {\n return (\n \n \n \n {children}\n \n \n \n );\n}\n\n// =============================================================================\n// ComboboxList\n// =============================================================================\nexport interface ComboboxListProps extends ComboboxPrimitive.List.Props {}\n\nfunction ComboboxList({ className, ...props }: ComboboxListProps) {\n return (\n \n );\n}\n\n// =============================================================================\n// ComboboxItem\n// =============================================================================\nexport interface ComboboxItemProps extends ComboboxPrimitive.Item.Props {\n children: React.ReactNode;\n}\n\nfunction ComboboxItem({ className, children, ...props }: ComboboxItemProps) {\n return (\n \n {children}\n \n }\n >\n \n \n \n );\n}\n\n// =============================================================================\n// ComboboxGroup\n// =============================================================================\nexport interface ComboboxGroupProps extends ComboboxPrimitive.Group.Props {}\n\nfunction ComboboxGroup({ className, ...props }: ComboboxGroupProps) {\n return (\n \n );\n}\n\n// =============================================================================\n// ComboboxLabel\n// =============================================================================\nexport interface ComboboxLabelProps\n extends ComboboxPrimitive.GroupLabel.Props {}\n\nfunction ComboboxLabel({ className, ...props }: ComboboxLabelProps) {\n return (\n \n );\n}\n\n// =============================================================================\n// ComboboxCollection\n// =============================================================================\nexport interface ComboboxCollectionProps\n extends ComboboxPrimitive.Collection.Props {}\n\nfunction ComboboxCollection({ ...props }: ComboboxCollectionProps) {\n return (\n \n );\n}\n\n// =============================================================================\n// ComboboxEmpty\n// =============================================================================\nexport interface ComboboxEmptyProps extends ComboboxPrimitive.Empty.Props {}\n\nfunction ComboboxEmpty({ className, ...props }: ComboboxEmptyProps) {\n return (\n \n );\n}\n\n// =============================================================================\n// ComboboxSeparator\n// =============================================================================\nexport interface ComboboxSeparatorProps\n extends ComboboxPrimitive.Separator.Props {}\n\nfunction ComboboxSeparator({ className, ...props }: ComboboxSeparatorProps) {\n return (\n \n );\n}\n\n// =============================================================================\n// ComboboxChips\n// =============================================================================\nexport interface ComboboxChipsProps\n extends React.ComponentPropsWithRef,\n ComboboxPrimitive.Chips.Props {}\n\nconst ComboboxChips = ({\n className,\n ref,\n ...props\n}: ComboboxChipsProps & React.RefAttributes) => (\n \n);\nComboboxChips.displayName = \"ComboboxChips\";\n\n// =============================================================================\n// ComboboxChip\n// =============================================================================\nexport interface ComboboxChipProps extends ComboboxPrimitive.Chip.Props {\n /**\n * Show the remove button on the chip\n * @default true\n */\n showRemove?: boolean;\n}\n\nfunction ComboboxChip({\n className,\n children,\n showRemove = true,\n ...props\n}: ComboboxChipProps) {\n return (\n \n {children}\n {showRemove && (\n }\n >\n \n \n )}\n \n );\n}\n\n// =============================================================================\n// ComboboxChipsInput\n// =============================================================================\nexport interface ComboboxChipsInputProps\n extends ComboboxPrimitive.Input.Props {}\n\nfunction ComboboxChipsInput({ className, ...props }: ComboboxChipsInputProps) {\n return (\n \n );\n}\n\n// =============================================================================\n// useComboboxAnchor Hook\n// =============================================================================\nfunction useComboboxAnchor() {\n return React.useRef(null);\n}\n\nexport type { ComboboxRootProps as ComboboxProps } from \"@base-ui/react/combobox\";\n// =============================================================================\n// Exports\n// =============================================================================\nexport {\n Combobox,\n ComboboxChip,\n ComboboxChips,\n ComboboxChipsInput,\n ComboboxClear,\n ComboboxCollection,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxGroup,\n ComboboxInput,\n ComboboxItem,\n ComboboxLabel,\n ComboboxList,\n ComboboxSeparator,\n ComboboxTrigger,\n ComboboxValue,\n useComboboxAnchor,\n};\n",
"type": "registry:ui"
}
],
"type": "registry:ui"
}