Combobox
uiable/comboboxFreeComponent
Combobox component.
Live preview
live · rendered by the registry
Rendered by uiable on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://uiable.com/r/combobox.jsonSource
1"use client";23import { ComponentPropsWithRef, useRef } from "react";45import { Combobox as ComboboxPrimitive } from "@base-ui/react";67import { cn } from "@/lib/utils";8import { Button } from "@/components/ui/button";9import {10 InputGroup,11 InputGroupAddon,12 InputGroupButton,13 InputGroupInput14} from "@/components/ui/input-group";15import { ChevronDownIcon, XIcon, CheckIcon } from "lucide-react";1617const Combobox = ComboboxPrimitive.Root;1819function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {20 return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />;21}2223function ComboboxTrigger({24 className,25 children,26 ...props27}: ComboboxPrimitive.Trigger.Props) {28 return (29 <ComboboxPrimitive.Trigger30 data-slot="combobox-trigger"31 className={cn("[&_svg:not([class*='size-'])]:size-4", className)}32 {...props}33 >34 {children}35 <ChevronDownIcon className="pointer-events-none size-4" />36 </ComboboxPrimitive.Trigger>37 );38}3940function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {41 return (42 <ComboboxPrimitive.Clear43 data-slot="combobox-clear"44 render={<InputGroupButton variant="ghost" size="icon-xs" />}45 className={cn(className)}46 {...props}47 >48 <XIcon className="pointer-events-none" />49 </ComboboxPrimitive.Clear>50 );51}5253function ComboboxInput({54 className,55 children,56 disabled = false,57 showTrigger = true,58 showClear = false,59 ...props60}: ComboboxPrimitive.Input.Props & {61 showTrigger?: boolean;62 showClear?: boolean;63}) {64 return (65 <InputGroup className={cn("w-auto", className)}>66 <ComboboxPrimitive.Input67 render={<InputGroupInput disabled={disabled} />}68 {...props}69 />70 <InputGroupAddon align="inline-end">71 {showTrigger && (72 <InputGroupButton73 size="icon-xs"74 variant="ghost"75 render={<ComboboxTrigger />}76 data-slot="input-group-button"77 className="group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent"78 disabled={disabled}79 />80 )}81 {showClear && <ComboboxClear disabled={disabled} />}82 </InputGroupAddon>83 {children}84 </InputGroup>85 );86}8788function ComboboxContent({89 className,90 side = "bottom",91 sideOffset = 6,92 align = "start",93 alignOffset = 0,94 anchor,95// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from uiable
All 712 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | uiable | Components | Free | 2 deps | |
| Alertalert | uiable | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | uiable | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | uiable | Components | Free | no deps | |
| Attachmentattachment | uiable | Components | Free | 2 deps | |
| Avataravatar | uiable | Components | Free | 1 dep | |
| Badgebadge | uiable | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | uiable | Components | Free | 2 deps |
