BNA

BNA UI
24

Combobox

A searchable dropdown component that combines an input with a list of options.

Installation

pnpm dlx bna-ui add combobox

Usage

import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxGroup,
  ComboboxInput,
  ComboboxItem,
  ComboboxList,
  ComboboxTrigger,
  ComboboxValue,
} from '@/components/ui/combobox';
<Combobox value={value} onValueChange={setValue}>
  <ComboboxTrigger>
    <ComboboxValue placeholder='Select framework...' />
  </ComboboxTrigger>
  <ComboboxContent>
    <ComboboxInput placeholder='Search frameworks...' />
    <ComboboxList>
      <ComboboxEmpty>No framework found.</ComboboxEmpty>
      <ComboboxItem value='react'>React</ComboboxItem>
      <ComboboxItem value='vue'>Vue</ComboboxItem>
      <ComboboxItem value='angular'>Angular</ComboboxItem>
    </ComboboxList>
  </ComboboxContent>
</Combobox>

Examples

Default

With Groups

Multiple Selection

Disabled

Form Integration

Large Dataset

API Reference

Combobox

The root component that manages the state and context for all child components.

PropTypeDefaultDescription
childrenReactNode-The combobox components.
valuestring""The selected value (single selection).
onValueChange(value: string) => void-Callback when single value changes.
valuesstring[][]The selected values (multiple selection).
onValuesChange(values: string[]) => void-Callback when multiple values change.
disabledbooleanfalseWhether the combobox is disabled.
multiplebooleanfalseWhether multiple selection is enabled.

ComboboxTrigger

The button that triggers the combobox dropdown.

PropTypeDefaultDescription
childrenReactNode-The trigger content (usually ComboboxValue).
styleViewStyle-Additional styles for the trigger.
errorbooleanfalseWhether to show error styling.

ComboboxValue

Displays the selected value or placeholder text.

PropTypeDefaultDescription
placeholderstring"Select..."Placeholder text when no value.
styleTextStyle-Additional styles for the text.

ComboboxContent

The modal container for the dropdown content.

PropTypeDefaultDescription
childrenReactNode-The dropdown content.
maxHeightnumber400Maximum height of the dropdown.

ComboboxInput

The search input field within the dropdown.

PropTypeDefaultDescription
placeholderstring"Search..."Placeholder text for the input.
styleViewStyle-Additional styles for the container.
autoFocusbooleantrueWhether to auto-focus the input.

ComboboxList

Container for the list of options with filtering capability.

PropTypeDefaultDescription
childrenReactNode-The list items and groups.
styleViewStyle-Additional styles for the list.

ComboboxEmpty

Displays when no items match the search query.

PropTypeDefaultDescription
childrenReactNode-The empty state content.
styleViewStyle-Additional styles for the container.

ComboboxGroup

Groups related options with an optional heading.

PropTypeDefaultDescription
childrenReactNode-The group items.
headingstring-Optional heading for the group.

ComboboxItem

Individual selectable option within the combobox.

PropTypeDefaultDescription
childrenReactNode-The item content.
valuestring-The value of the item.
onSelect(value: string) => void-Callback when item is selected.
disabledbooleanfalseWhether the item is disabled.
searchValuestring-Custom value for search filtering.
styleViewStyle-Additional styles for the item.

Accessibility

The Combobox component is built with accessibility in mind:

  • Full keyboard navigation support
  • Screen reader compatible with proper ARIA attributes
  • Focus management between trigger and dropdown
  • Escape key closes the dropdown
  • Search functionality works with assistive technologies
  • Proper color contrast for all states
  • Supports dynamic text sizing

Keyboard Shortcuts

  • Space/Enter: Open dropdown when trigger is focused
  • Escape: Close dropdown
  • Arrow Keys: Navigate through options
  • Enter: Select highlighted option
  • Tab: Move focus to next element
  • Type: Search for matching options