Combobox
shadcn-htmx/comboboxFreeComponent
Autocomplete text input. Native <datalist> variant (zero JS) + APG role=combobox + htmx-filtered listbox variant.
Live preview
live · rendered by the registry
Rendered by shadcn-htmx on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-htmx.productdevbook.com/r/combobox.jsonSource
1/** @jsxImportSource hono/jsx */2import { cn, type ClassValue } from "@/registry/lib/cn"34// Combobox — shadcn-htmx, htmx v4 + Tailwind v4.5//6// **Native-first.** This component is just `<input list>` + `<datalist>`.7// The browser handles:8// - The dropdown UI9// - Filtering as the user types10// - Click + keyboard selection11// - Focus management12// - aria-controls / aria-expanded wiring (implicit)13//14// No custom JS event handlers, no MutationObserver, no race conditions.15// If you need server-driven suggestions, point htmx at the <datalist> and16// have the server return `<option>` tags — the browser uses them17// transparently.18//19// Refs:20// repos/mdn/files/en-us/web/html/reference/elements/datalist/index.md21// repos/mdn/files/en-us/web/html/reference/elements/input/index.md#list22// repos/aria-practices/content/patterns/combobox/2324// `disabled` marks an option non-checkable (browsers grey it out, it gets25// no click/focus events).26// repos/mdn/files/en-us/web/html/reference/elements/option/index.md:4527export type ComboboxOption = { value: string; label?: string; disabled?: boolean }2829type ComboboxProps = {30 // The input's id. The <datalist> gets `${id}-list`; if you wire htmx31 // to fetch options dynamically, target that id.32 id: string33 name?: string34 // Initial options. Server-filtered comboboxes can pass [] and let35 // htmx populate the datalist on input.36 options?: ComboboxOption[]37 // `list` is valid on these 13 input types, not just text — a url/email/38 // search combobox, or a number/date/time/range/color picker with suggested39 // values, are all native datalist use cases.40 // repos/mdn/files/en-us/web/html/reference/elements/input/index.md:49241 type?:42 | "text"43 | "search"44 | "url"45 | "tel"46 | "email"47 | "number"48 | "date"49 | "datetime-local"50 | "month"51 | "week"52 | "time"53 | "range"54 | "color"55 placeholder?: string56 value?: string57 required?: boolean58 disabled?: boolean59 // The user can type any value that passes validation, even one not in the60 // suggestion list, so constrain the free-typed value with these.61 // repos/mdn/files/en-us/web/html/reference/elements/input/index.md:50562 maxlength?: number63 minlength?: number64 pattern?: string65 // Explains the pattern to AT / on validation failure (spec accessibility note).66 title?: string67 // Focusable + copy-selectable but not editable. Not supported on range/color.68// … truncated
More from shadcn-htmx
All 83 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | shadcn-htmx | Components | Free | no deps | |
| Active Searchactive-search | shadcn-htmx | Components | Free | no deps | |
| Alertalert | shadcn-htmx | Components | Free | no deps | |
| Alert Dialogalert-dialog | shadcn-htmx | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | shadcn-htmx | Components | Free | no deps | |
| Auto Gridauto-grid | shadcn-htmx | Components | Free | no deps | |
| Autocompleteautocomplete | shadcn-htmx | Components | Free | no deps | |
| Autosize Textareaautosize-textarea | shadcn-htmx | Components | Free | no deps |
