Combobox
solid-ui/comboboxFreeComponent
A combobox component
Live preview
live · rendered by the registry
Rendered by solid-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solid-ui.com/r/combobox.jsonSource
1import type { JSX, ValidComponent } from "solid-js"2import { Show, splitProps } from "solid-js"34import * as ComboboxPrimitive from "@kobalte/core/combobox"5import type { PolymorphicProps } from "@kobalte/core/polymorphic"67import { cn } from "~/lib/utils"89const Combobox = ComboboxPrimitive.Root10const ComboboxItemLabel = ComboboxPrimitive.ItemLabel11const ComboboxHiddenSelect = ComboboxPrimitive.HiddenSelect1213type ComboboxItemProps<T extends ValidComponent = "li"> = ComboboxPrimitive.ComboboxItemProps<T> & {14 class?: string | undefined15}1617const ComboboxItem = <T extends ValidComponent = "li">(18 props: PolymorphicProps<T, ComboboxItemProps<T>>19) => {20 const [local, others] = splitProps(props as ComboboxItemProps, ["class"])21 return (22 <ComboboxPrimitive.Item23 class={cn(24 "relative flex cursor-default select-none items-center justify-between rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:opacity-50",25 local.class26 )}27 {...others}28 />29 )30}3132type ComboboxItemIndicatorProps<T extends ValidComponent = "div"> =33 ComboboxPrimitive.ComboboxItemIndicatorProps<T> & {34 children?: JSX.Element35 }3637const ComboboxItemIndicator = <T extends ValidComponent = "div">(38 props: PolymorphicProps<T, ComboboxItemIndicatorProps<T>>39) => {40 const [local, others] = splitProps(props as ComboboxItemIndicatorProps, ["children"])41 return (42 <ComboboxPrimitive.ItemIndicator {...others}>43 <Show44 when={local.children}45 fallback={46 <svg47 xmlns="http://www.w3.org/2000/svg"48 viewBox="0 0 24 24"49 fill="none"50 stroke="currentColor"51 stroke-width="2"52 stroke-linecap="round"53 stroke-linejoin="round"54 class="size-4"55 >56 <path d="M5 12l5 5l10 -10" />57 </svg>58 }59 >60 {(children) => children()}61 </Show>62 </ComboboxPrimitive.ItemIndicator>63 )64}6566type ComboboxSectionProps<T extends ValidComponent = "li"> =67 ComboboxPrimitive.ComboboxSectionProps<T> & { class?: string | undefined }6869const ComboboxSection = <T extends ValidComponent = "li">(70 props: PolymorphicProps<T, ComboboxSectionProps<T>>71) => {72 const [local, others] = splitProps(props as ComboboxSectionProps, ["class"])73 return (74 <ComboboxPrimitive.Section75 class={cn(76// … truncated
What it pulls in
npm packages
Files it writes
More from solid-ui
All 55 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | solid-ui | Components | Free | 2 deps | |
| Alertalert | solid-ui | Components | Free | 3 deps | |
| Alert Dialogalert-dialog | solid-ui | Components | Free | 2 deps | |
| Aspect Ratioaspect-ratio | solid-ui | Components | Free | 1 dep | |
| Avataravatar | solid-ui | Components | Free | 2 deps | |
| Badgebadge | solid-ui | Components | Free | 2 deps | |
| Badge Deltabadge-delta | solid-ui | Components | Free | 2 deps | |
| Bar Listbar-list | solid-ui | Components | Free | 1 dep |
