NUIv3.0.7

Combobox

A composable, accessible Combobox component for modern React applications.

tsx
import { Combobox } from '@nofinite/nui';

Interactive Preview

Loading preview...

A searchable dropdown input component that allows users to filter and select options from a list. Supports controlled/uncontrolled usage, keyboard navigation, icons, custom rendering, filtering, and accessibility-compliant listbox behavior.


Usage

Basic Combobox

tsx
import { Combobox } from '@nofinite/nui';

<Combobox
  options={[
    { label: "React", value: "react" },
    { label: "Vue", value: "vue" },
    { label: "Angular", value: "angular" }
  ]}
/>

Controlled Combobox

tsx
const [value, setValue] = useState("");

<Combobox
  value={value}
  onChange={setValue}
  options={options}
/>

Combobox with Icons

tsx
<Combobox
  leftIcon={<Icon />}
  rightIcon={<Icon />}
  options={options}
/>

Custom Option Rendering

tsx
<Combobox
  options={options}
  renderOption={(opt, active) => (
    <span style={{ fontWeight: active ? 600 : 400 }}>
      {opt.label}
    </span>
  )}
/>

Custom Filter

tsx
<Combobox
  options={options}
  filter={(input, option) =>
    option.label.toLowerCase().startsWith(input.toLowerCase())
  }
/>


Variants

Combobox supports interaction-based variants.

tsx
<Combobox options={options} />              // Default combobox
<Combobox disabled options={options} />     // Disabled combobox
<Combobox leftIcon={<Icon />} />            // With icons
<Combobox renderOption={() => {}} />        // Custom rendered options

Available variants:

  • default – Standard searchable combobox
  • disabled – Non-interactive combobox
  • icon – Combobox with input icons
  • custom-render – Combobox with custom option rendering

Guidelines:

  • Use default for general dropdown selection.
  • Use disabled to prevent interaction when unavailable.
  • Use icon for contextual affordances.
  • Use custom-render for complex option UI.

States

StateDescription
defaultClosed combobox
openDropdown visible
activeKeyboard-highlighted option
selectedCurrently selected option
emptyNo results state


Accessibility

  • Uses ARIA combobox + listbox pattern

  • Supports full keyboard navigation

    • Arrow keys for navigation
    • Enter for selection
    • Escape to close
  • aria-expanded, aria-controls, and aria-activedescendant ensure screen reader support

  • Click-outside handling prevents accidental focus loss

  • Option selection correctly updates aria-selected


Best Practices

Do

  • Use combobox for searchable selections
  • Provide meaningful empty state message
  • Use custom filter for large datasets
  • Keep option labels concise
  • Use icons for recognition

Don’t

  • Use combobox for very small lists without search need
  • Hide essential information inside custom renderers
  • Disable keyboard navigation
  • Overload options with long content

API Reference

PropTypeDefaultDescription
data*ComboboxOption[]
valuestringControlled value of the combobox
defaultValuestringInitial uncontrolled value
onChange((value: string) => void)Callback fired when an option is selected
placeholderstringSelect...
disabledbooleanfalse
emptyMessagestringNo results foundMessage displayed when filtering returns zero results
filter((input: string, option: ComboboxOption) => boolean)Custom filter function. Defaults to simple substring matching on the label.
leftIconReactNode
rightIconReactNode
renderOption((option: ComboboxOption, active: boolean) => ReactNode)Custom renderer for the entire option row
renderOptionIcon((option: ComboboxOption) => ReactNode)Custom renderer strictly for the option's icon