NOCTA UI

Combobox

Searchable combobox component with filtering, keyboard navigation, and accessibility for advanced option selection

Installation

Install the Combobox component using the nocta-ui CLI:

npx nocta-ui add combobox

Import the component:

import { Combobox, ComboboxOption } from '@/components/ui/combobox';

Examples

The Combobox component provides a searchable dropdown interface for selecting from a list of options.

Variants

The Combobox component supports three visual variants: default, error, and success.

This field is required

Selection confirmed

Sizes

Three size options are available: sm, md, and lg. The default size is md.

Clearable Selection

Control whether users can clear their selection with an X button.

X button appears when value is selected

No clear button shown

Disabled Options

Individual options can be disabled by setting the disabled property.

Some options are disabled (e.g., PHP)

Disabled State

The entire combobox can be disabled.

Entire combobox is disabled

Custom Messages

Customize the empty state message when no options match the search.

Type something that doesn't match to see custom message

Controlled vs Uncontrolled

Use defaultValue for uncontrolled behavior:

<Combobox
  options={options}
  defaultValue="react"
  onValueChange={(value) => console.log('Selected:', value)}
/>

Controlled

Use value and onValueChange for controlled behavior:

Current value: react

Api Reference

Combobox

PropTypeDefaultDescription
optionsComboboxOption[]Array of selectable options
valuestringControlled selected value
defaultValuestringDefault selected value
onValueChange(value: string) => voidCallback when selection changes
portalbooleantrueRender the combobox in a React portal
placeholderstring'Select option...'Placeholder text
searchPlaceholderstring'Search...'Search input placeholder
emptyMessagestring'No options found'Message when no options match
disabledbooleanfalseDisable the combobox
size'sm' | 'md' | 'lg''md'Size variant
variant'default' | 'error' | 'success''default'Visual variant
classNamestring''Additional CSS classes for trigger
popoverClassNamestring''Additional CSS classes for dropdown
clearablebooleantrueShow clear button when value selected

ComboboxOption

PropTypeDefaultDescription
valuestringUnique option identifier
labelstringDisplay text for the option
disabledbooleanfalseDisable this option

The Combobox component also accepts all standard HTML button attributes for the trigger element.