Skip to content
nexubDesign System
v11.9.0

Components · Form Controls

Combobox Field

AlphaAdded v11.1.0

A labelled, searchable single choice that looks like a Select. For lists longer than about ten options.

import { ComboboxField } from '@nexub/react';
View as Markdown

Usage

Use it for
  • One choice from a long list: people, countries, companies, codes.

  • A list the server searches (`onSearch` with `loading`).

Use something else for
  • Ten options or fewer: use Select.

  • Several choices: use MultiSelect.

  • Free text with suggestions: use Autocomplete.

Playground

Props

size

Where the company is registered

TSX
<ComboboxField label="Country" description="Where the company is registered" options={countries} value={value} onValueChange={setValue} />

Examples

Default

Where the company is registered

Groups and a none option

States

  • Where the company is registered

    default
  • Where the company is registered

    disabled
  • Where the company is registered

    invalid
  • Where the company is registered

    readOnly
  • Where the company is registered

    loading
  • Where the company is registered

    size="sm"
  • Where the company is registered

    size="md"
  • Where the company is registered

    size="lg"

Props

Props
PropTypeDefaultDescription
labelrequiredReact.ReactNode—The field label. ComboboxPicker is the same control without it (name it with aria-label).
optionsrequiredComboboxOption[]—{ value, label, description?, keywords?, disabled?, group? }. description is a second line; keywords and description are searched too; group lists the option under a heading.
valuestring—The picked value, null for none.
defaultValuestringnullThe picked value, null for none.
onValueChange((value: string) => void)—Called with the picked value, or null from the none option.
noneOptionstring—A first option that clears the value, e.g. "No manager".
onSearch((text: string) => void)—Server search: the list is not filtered here while onSearch is set.
loadingboolean—Server search: the list is not filtered here while onSearch is set.
selectedOptionComboboxOption—Labels the value when it is not in options (before an async search has run).
descriptionReact.ReactNode—Help and the inline error under the field. error marks it invalid.
errorReact.ReactNode—Help and the inline error under the field. error marks it invalid.
namestring—A hidden input posts the value with a plain form. Inside Form, also picks up the form error.
size'sm' | 'md' | 'lg''md'Height of the field.
sheetfalse | true | 'auto''auto' (a bottom sheet below 768px)The list as a bottom sheet below 768px.
aria-describedbystring—
aria-invalidfalse | true | 'true' | 'false'—
aria-labelstring—
aria-requiredfalse | true | 'true' | 'false'—
classNamestring—
disabledboolean—
emptyTextReact.ReactNode'No results found.'Shown when the search finds nothing.
idstring—
invalidboolean—
placeholderstring'Select…'Shown when nothing is picked.
readOnlyboolean—Shows the value; the list can't open. Stays focusable.
requiredboolean—
searchPlaceholderstring'Search…'The search box's placeholder.

Accessibility

Keyboard

  • Enter / Space / Arrow Down

    Opens the list with focus in the search box.

  • Arrow Up / Arrow Down

    Moves through the options.

  • Enter

    Picks the highlighted option and closes.

  • Escape

    Closes without changing the value.

Notes

  • The trigger is a `combobox` named by the label; the picked option is its text.

  • Description and error are linked with `aria-describedby`.

On iOS & Android