Skip to Content
Neshel-UI
Components

Combobox

A filterable text input for single or multiple selection, with groups and external filtering.

Client component ("use client")

Purpose

Combobox lets users type to filter a list and pick one value (default) or several (multiple). The value is always one of the items — it is not a free-text input.

Import

import.tsx
import { Combobox } from "@neshel-ui/components";

Single mode

Preview: combobox-single
Preview theme
combobox-single.tsx
import { Combobox, Label } from "@neshel-ui/components";
import { Stack } from "@neshel-ui/layout";

const destinations = [
  {
    label: "Americas",
    items: [
      { value: "cr", label: "Costa Rica" },
      { value: "pe", label: "Peru" },
      { value: "ca", label: "Canada" },
    ],
  },
  {
    label: "Europe",
    items: [
      { value: "es", label: "Spain" },
      { value: "pt", label: "Portugal" },
    ],
  },
  {
    label: "Asia",
    items: [
      { value: "jp", label: "Japan" },
      { value: "vn", label: "Vietnam" },
    ],
  },
];

export default function ComboboxSingle() {
  return (
    <Stack space="2" className="max-w-sm">
      <Label htmlFor="combobox-destination">Destination</Label>
      <Combobox
        id="combobox-destination"
        name="destination"
        items={destinations}
        placeholder="Search a country"
      />
    </Stack>
  );
}

Multiple mode

Preview: combobox-multiple
Preview theme
combobox-multiple.tsx
import { Combobox, Label } from "@neshel-ui/components";
import { Stack } from "@neshel-ui/layout";

const technologies = [
  { value: "ts", label: "TypeScript" },
  { value: "rs", label: "Rust" },
  { value: "go", label: "Go" },
  { value: "py", label: "Python" },
  { value: "kt", label: "Kotlin" },
];

export default function ComboboxMultiple() {
  return (
    <Stack space="2" className="max-w-md">
      <Label htmlFor="combobox-tech">Technologies</Label>
      <Combobox
        id="combobox-tech"
        name="technologies"
        multiple
        items={technologies}
        defaultValue={["ts"]}
        placeholder="Select technologies"
      />
    </Stack>
  );
}

Pass filter={null}, update items from onInputValueChange, and set loading while fetching. Selected chips keep their labels when the results change.

Preview: combobox-async
Preview theme
value: []
combobox-async.tsx
"use client";
import { Combobox, Label } from "@neshel-ui/components";
import { Stack } from "@neshel-ui/layout";
import { Text } from "@neshel-ui/typography";
import { useEffect, useState } from "react";

const catalogue = [
  { value: "ts", label: "TypeScript" },
  { value: "rs", label: "Rust" },
  { value: "go", label: "Go" },
  { value: "py", label: "Python" },
  { value: "kt", label: "Kotlin" },
  { value: "sw", label: "Swift" },
];

/** External filtering: the application owns the items (here a simulated request). */
export default function ComboboxAsync() {
  const [query, setQuery] = useState("");
  const [items, setItems] = useState(catalogue);
  const [loading, setLoading] = useState(false);
  const [value, setValue] = useState<string[]>([]);

  useEffect(() => {
    setLoading(true);
    const timer = setTimeout(() => {
      setItems(catalogue.filter((item) => item.label.toLowerCase().includes(query.toLowerCase())));
      setLoading(false);
    }, 400);
    return () => clearTimeout(timer);
  }, [query]);

  return (
    <Stack space="2" className="max-w-md">
      <Label htmlFor="combobox-async">Technologies (server search)</Label>
      <Combobox
        id="combobox-async"
        multiple
        items={items}
        filter={null}
        loading={loading}
        inputValue={query}
        onInputValueChange={setQuery}
        value={value}
        onValueChange={setValue}
        placeholder="Type to search"
      />
      <Text tone="muted" size="sm">
        value: {JSON.stringify(value)}
      </Text>
    </Stack>
  );
}

API

ComboboxProps

ComboboxProps
PropTypeDefaultDescription
aria-describedbystring——
aria-labelstring——
aria-labelledbystring——
classNamestring——
clearLabelstring"Clear selection"Accessible name of the clear button (default "Clear selection").
clearablebooleantrueShow a clear button when a value is selected (default true).
containerHTMLElement | null—Portal target for the popup (default: the enclosing Neshel overlay, else document.body).
defaultInputValuestring—Initial text of the input when uncontrolled.
defaultOpenboolean——
defaultValuestring | null | readonly string[]—Initial selected value when uncontrolled.
disabledboolean——
emptyMessageReactNode"No results"Shown when no item matches (default "No results").
filter((item: ComboboxItem, query: string) => boolean) | null—Local filter (default: case-insensitive label match); null when the app filters items.
formstring——
idstring—Id of the focusable control; associate a <Label htmlFor> with it.
inputValuestring—Controlled text of the input.
invalidboolean—Marks the control aria-invalid. Describe the error with aria-describedby.
items(required)readonly ComboboxItem[] | readonly ComboboxItemGroup[]—Items, or groups of items (not mixed).
loadingboolean—Shows loadingMessage while external results load.
loadingMessageReactNode"Loading…"Loading text (default "Loading…").
multipleboolean—Single selection (default).
namestring—Form field name; one entry per selected value.
onInputValueChange(value: string) => void—Called when the user types; use with filter={null} for server-side search.
onOpenChange(open: boolean) => void——
onValueChange(value: string | null) => void | (value: string[]) => void—Called with the new value (null when cleared).
openboolean——
placeholderstring—Text shown when nothing is selected.
readOnlyboolean——
refRef<HTMLInputElement>——
removeLabel(label: string) => stringRemove <label>Accessible name of a chip's remove button (default: Remove <label>).
requiredboolean——
triggerLabelstring"Show options"Accessible name of the button that opens the list (default "Show options").
uiSizeFieldSize"md"Field size (default "md").
valuestring | null | readonly string[]—Controlled selected value (null = none).

ComboboxSingleProps

ComboboxSingleProps
PropTypeDefaultDescription
aria-describedbystring——
aria-labelstring——
aria-labelledbystring——
classNamestring——
clearLabelstring"Clear selection"Accessible name of the clear button (default "Clear selection").
clearablebooleantrueShow a clear button when a value is selected (default true).
containerHTMLElement | null—Portal target for the popup (default: the enclosing Neshel overlay, else document.body).
defaultInputValuestring—Initial text of the input when uncontrolled.
defaultOpenboolean——
defaultValuestring | null—Initial selected value when uncontrolled.
disabledboolean——
emptyMessageReactNode"No results"Shown when no item matches (default "No results").
filter((item: ComboboxItem, query: string) => boolean) | null—Local filter (default: case-insensitive label match); null when the app filters items.
formstring——
idstring—Id of the focusable control; associate a <Label htmlFor> with it.
inputValuestring—Controlled text of the input.
invalidboolean—Marks the control aria-invalid. Describe the error with aria-describedby.
items(required)readonly ComboboxItem[] | readonly ComboboxItemGroup[]—Items, or groups of items (not mixed).
loadingboolean—Shows loadingMessage while external results load.
loadingMessageReactNode"Loading…"Loading text (default "Loading…").
multiplefalse—Single selection (default).
namestring—Form field name; one entry per selected value.
onInputValueChange(value: string) => void—Called when the user types; use with filter={null} for server-side search.
onOpenChange(open: boolean) => void——
onValueChange(value: string | null) => void—Called with the new value (null when cleared).
openboolean——
placeholderstring—Text shown when nothing is selected.
readOnlyboolean——
refRef<HTMLInputElement>——
requiredboolean——
triggerLabelstring"Show options"Accessible name of the button that opens the list (default "Show options").
uiSizeFieldSize"md"Field size (default "md").
valuestring | null—Controlled selected value (null = none).

ComboboxMultipleProps

ComboboxMultipleProps
PropTypeDefaultDescription
aria-describedbystring——
aria-labelstring——
aria-labelledbystring——
classNamestring——
clearLabelstring"Clear selection"Accessible name of the clear button (default "Clear selection").
clearablebooleantrueShow a clear button when a value is selected (default true).
containerHTMLElement | null—Portal target for the popup (default: the enclosing Neshel overlay, else document.body).
defaultInputValuestring—Initial text of the input when uncontrolled.
defaultOpenboolean——
defaultValuereadonly string[]—Initial selected values when uncontrolled.
disabledboolean——
emptyMessageReactNode"No results"Shown when no item matches (default "No results").
filter((item: ComboboxItem, query: string) => boolean) | null—Local filter (default: case-insensitive label match); null when the app filters items.
formstring——
idstring—Id of the focusable control; associate a <Label htmlFor> with it.
inputValuestring—Controlled text of the input.
invalidboolean—Marks the control aria-invalid. Describe the error with aria-describedby.
items(required)readonly ComboboxItem[] | readonly ComboboxItemGroup[]—Items, or groups of items (not mixed).
loadingboolean—Shows loadingMessage while external results load.
loadingMessageReactNode"Loading…"Loading text (default "Loading…").
multiple(required)true—Multiple selection with removable chips.
namestring—Form field name; one entry per selected value.
onInputValueChange(value: string) => void—Called when the user types; use with filter={null} for server-side search.
onOpenChange(open: boolean) => void——
onValueChange(value: string[]) => void—Called with the new list of values.
openboolean——
placeholderstring—Text shown when nothing is selected.
readOnlyboolean——
refRef<HTMLInputElement>——
removeLabel(label: string) => stringRemove <label>Accessible name of a chip's remove button (default: Remove <label>).
requiredboolean——
triggerLabelstring"Show options"Accessible name of the button that opens the list (default "Show options").
uiSizeFieldSize"md"Field size (default "md").
valuereadonly string[]—Controlled selected values.

ComboboxItem

ComboboxItem
PropTypeDefaultDescription
disabledboolean——
label(required)string—Visible text (also used for typeahead and chips).
value(required)string—Value submitted with the form and passed to onValueChange.

ComboboxItemGroup

ComboboxItemGroup
PropTypeDefaultDescription
items(required)readonly ComboboxItem[]—Items of the group.
label(required)string—Group heading.

ComboboxProps is the union of the single and multiple variants: with multiple, value is a string[]; without it, string | null.

Controlled and uncontrolled

  • Value: value / defaultValue / onValueChange.
  • Input text: inputValue / defaultInputValue / onInputValueChange.
  • Popup: open / defaultOpen / onOpenChange.

Forms

With name, the selected value (or each value in multiple mode) is submitted.

Accessibility

  • The input is a combobox controlling a listbox; the active option is announced as you move.
  • emptyMessage ("No results") and loadingMessage ("Loading…") are announced in the popup.
  • Escape closes the popup and never clears the value; clear with the clear button or Backspace on chips.
  • Inside a Dialog or Popover, the popup renders inside that overlay; Escape closes the popup first.

Keyboard

KeyAction
TypeFilter the items (opens the popup)
↓ / ↑Move between items
EnterSelect the active item
EscapeClose the popup
Backspace (empty input, multiple)Remove the last chip

Common mistakes

  • Expecting free text: values must be items. For suggestions with free text, use <Input list="…"> and a <datalist>.
  • Filtering both locally and on the server: pass filter={null} when the application filters.
Edit on GitHub

On this page