Combobox

A searchable dropdown for filtering and selecting from a list of options.

Import

import { Combobox } from '@oztix/roadie-components/combobox'

Examples

Default

function ComboboxDefault() {
  const bands = [
    'Powderfinger',
    'Custard',
    'Regurgitator',
    'The Go-Betweens',
    'Violent Soho',
    'DZ Deathrays',
    'Ball Park Music',
    'The Goon Sax',
    'Cub Sport',
    'The Jungle Giants',
  ]

  return (
    <Combobox items={bands}>
      <Combobox.InputGroup>
        <Combobox.Input placeholder='Search bands...' />
        <Combobox.Trigger />
      </Combobox.InputGroup>
      <Combobox.Portal>
        <Combobox.Positioner>
          <Combobox.Popup>
            <Combobox.List>
              {(band) => (
                <Combobox.Item key={band} value={band}>
                  {band}
                  <Combobox.ItemIndicator />
                </Combobox.Item>
              )}
            </Combobox.List>
            <Combobox.Empty>No bands found</Combobox.Empty>
          </Combobox.Popup>
        </Combobox.Positioner>
      </Combobox.Portal>
    </Combobox>
  )
}

Emphasis

<div className='grid gap-2'>
  <Combobox>
    <Combobox.InputGroup emphasis='normal'>
      <Combobox.Input placeholder='Normal emphasis' />
      <Combobox.Trigger />
    </Combobox.InputGroup>
  </Combobox>
  <Combobox>
    <Combobox.InputGroup emphasis='subtle'>
      <Combobox.Input placeholder='Subtle emphasis' />
      <Combobox.Trigger />
    </Combobox.InputGroup>
  </Combobox>
</div>

Sizes

<div className='grid gap-2'>
  <Combobox>
    <Combobox.InputGroup size='sm'>
      <Combobox.Input placeholder='Small' />
      <Combobox.Trigger />
    </Combobox.InputGroup>
  </Combobox>
  <Combobox>
    <Combobox.InputGroup size='md'>
      <Combobox.Input placeholder='Medium (default)' />
      <Combobox.Trigger />
    </Combobox.InputGroup>
  </Combobox>
  <Combobox>
    <Combobox.InputGroup size='lg'>
      <Combobox.Input placeholder='Large' />
      <Combobox.Trigger />
    </Combobox.InputGroup>
  </Combobox>
</div>

States

<div className='grid gap-4'>
  <div className='grid gap-1'>
    <p className='text-sm text-subtle'>Default</p>
    <Combobox>
      <Combobox.InputGroup>
        <Combobox.Input placeholder='Search...' />
        <Combobox.Trigger />
      </Combobox.InputGroup>
    </Combobox>
  </div>
  <div className='grid gap-1'>
    <p className='text-sm text-subtle'>Disabled</p>
    <Combobox disabled>
      <Combobox.InputGroup>
        <Combobox.Input placeholder='Search...' />
        <Combobox.Trigger />
      </Combobox.InputGroup>
    </Combobox>
  </div>
</div>

Composition

With Field

Wrap Combobox in Field for consistent layout, labels, and error handling. Field.Label's htmlFor wires directly to the Combobox input — clicking the label focuses the search field.

function ComboboxWithField() {
  const bands = [
    'Powderfinger',
    'Custard',
    'Regurgitator',
    'Violent Soho',
    'DZ Deathrays',
    'Ball Park Music',
  ]

  return (
    <Field required>
      <Field.Label showIndicator>Favourite band</Field.Label>
      <Combobox items={bands}>
        <Combobox.InputGroup>
          <Combobox.Input placeholder='Search bands...' />
          <Combobox.Clear />
          <Combobox.Trigger />
        </Combobox.InputGroup>
        <Combobox.Portal>
          <Combobox.Positioner>
            <Combobox.Popup>
              <Combobox.List>
                {(band) => (
                  <Combobox.Item key={band} value={band}>
                    {band}
                    <Combobox.ItemIndicator />
                  </Combobox.Item>
                )}
              </Combobox.List>
              <Combobox.Empty>No bands found</Combobox.Empty>
            </Combobox.Popup>
          </Combobox.Positioner>
        </Combobox.Portal>
      </Combobox>
    </Field>
  )
}

With groups

function ComboboxWithGroups() {
  const groups = [
    {
      value: 'Brisbane',
      items: ['Powderfinger', 'Custard', 'Regurgitator', 'The Go-Betweens', 'The Saints'],
    },
    {
      value: 'Gold Coast',
      items: ['Violent Soho', 'DZ Deathrays', 'The Goon Sax', 'Cub Sport'],
    },
  ]

  return (
    <Combobox items={groups}>
      <Combobox.InputGroup>
        <Combobox.Input placeholder='Search by region...' />
        <Combobox.Trigger />
      </Combobox.InputGroup>
      <Combobox.Portal>
        <Combobox.Positioner>
          <Combobox.Popup>
            <Combobox.List>
              {groups.map((group) => (
                <Combobox.Group key={group.value} items={group.items}>
                  <Combobox.GroupLabel>{group.value}</Combobox.GroupLabel>
                  <Combobox.Collection>
                    {(band) => (
                      <Combobox.Item key={band} value={band}>
                        {band}
                        <Combobox.ItemIndicator />
                      </Combobox.Item>
                    )}
                  </Combobox.Collection>
                </Combobox.Group>
              ))}
            </Combobox.List>
            <Combobox.Empty>No bands found</Combobox.Empty>
          </Combobox.Popup>
        </Combobox.Positioner>
      </Combobox.Portal>
    </Combobox>
  )
}

With rich items

Use custom markup inside Combobox.Item to show metadata like a subtitle or secondary label alongside the primary text.

function ComboboxRichItems() {
  const venues = [
    { name: 'The Tivoli', location: 'Fortitude Valley, QLD' },
    { name: 'The Triffid', location: 'Newstead, QLD' },
    { name: 'The Zoo', location: 'Fortitude Valley, QLD' },
    { name: 'Woolly Mammoth', location: 'Fortitude Valley, QLD' },
    { name: 'The Princess Theatre', location: 'Woolloongabba, QLD' },
    { name: 'Riverstage', location: 'South Bank, QLD' },
    { name: 'The Fortitude Music Hall', location: 'Fortitude Valley, QLD' },
    { name: 'Black Bear Lodge', location: 'Fortitude Valley, QLD' },
  ]

  return (
    <Combobox items={venues} getOptionLabel={(venue) => venue.name} getOptionString={(venue) => venue.name}>
      <Combobox.InputGroup>
        <Combobox.Input placeholder='Search venues...' />
        <Combobox.Clear />
        <Combobox.Trigger />
      </Combobox.InputGroup>
      <Combobox.Portal>
        <Combobox.Positioner>
          <Combobox.Popup>
            <Combobox.List>
              {(venue) => (
                <Combobox.Item key={venue.name} value={venue.name}>
                  <div className='grid gap-0.5 min-w-0'>
                    <span className='truncate font-medium'>{venue.name}</span>
                    <span className='truncate text-xs text-subtle'>{venue.location}</span>
                  </div>
                  <Combobox.ItemIndicator />
                </Combobox.Item>
              )}
            </Combobox.List>
            <Combobox.Empty>No venues found</Combobox.Empty>
          </Combobox.Popup>
        </Combobox.Positioner>
      </Combobox.Portal>
    </Combobox>
  )
}

Guidelines

When to use Combobox

Use Combobox when the user needs to search or filter a list, or when options are loaded from an API. The input lets users narrow results by typing — they usually know roughly what they're looking for.

  • Venue or event search
  • Assignee pickers (team members from an API)
  • Tag or category selection with many options
  • Any list over ~15 items
  • Lists that load asynchronously

When to use Select instead

If the list is short, fixed, and fully known (under ~15 items), use Select. Users browse rather than search — no text input needed.

Combobox vs Autocomplete

If the user's typed value is always valid and suggestions just help, use Autocomplete. Think address fields or search bars.

QuestionSelectComboboxAutocomplete
User types to filter?NoYesYes
Must pick from the list?YesYesNo — typed value is valid
Options from an API?NoYesYes
Custom/free-text value?NoNoYes
Primary interactionBrowse and pickSearch and pickType with suggestions
Typical list size2-15 items10-500+ itemsAny

Filtering

Pass the items prop to Combobox root for built-in client-side filtering. Use Combobox.List with a render function child to template each filtered item:

<Combobox items={bands}>
...
<Combobox.List>
{(band) => <Combobox.Item value={band}>{band}</Combobox.Item>}
</Combobox.List>
<Combobox.Empty>No results</Combobox.Empty>
</Combobox>

Combobox.Empty only renders when the filtered list is empty. It requires the items prop on root.

Async loading

For server-side search, update the items prop as results arrive. Use Combobox.Status to announce state changes to screen readers:

<Combobox items={results} onInputValueChange={(value) => fetchResults(value)}>
...
<Combobox.Status>{isLoading ? 'Loading...' : `${results.length} results`}</Combobox.Status>
</Combobox>

Keyboard behaviour

  • Arrow keys navigate the list
  • Enter confirms the highlighted item
  • Escape closes the popup
  • Typing filters the list in real time

Accessibility

  • Use a <label> or Combobox.Label to name the input.
  • Combobox.ItemIndicator shows a check on the selected item — include it for clarity.
  • Combobox.Empty announces "no results" to screen readers automatically.
  • Combobox.Status is a live region — use it for async status like loading or result counts.

API reference

Combobox

Base UI
filter?((itemValue: unknown, query: string, itemToString?: ((itemValue: unknown) => string)) => boolean) | null

Filter function used to match items vs input query.

disabled?boolean

Whether the component should ignore user interaction.

Defaults to false.

name?string

Identifies the field when a form is submitted.

id?string

The id of the component.

grid?boolean

Whether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows.

Defaults to false.

inline?boolean

Whether the list is rendered inline without using the popup.

Defaults to false.

items?readonly any[] | readonly Group<any>[]

The items to be displayed in the list. Can be either a flat array of items or an array of groups with items.

readOnly?boolean

Whether the user should be unable to choose a different option from the popup.

Defaults to false.

required?boolean

Whether the user must choose a value before submitting a form.

Defaults to false.

defaultOpen?boolean

Whether the popup is initially open. To render a controlled popup, use the `open` prop instead.

Defaults to false.

open?boolean

Whether the popup is currently open. Use when controlled.

onOpenChangeComplete?((open: boolean) => void)

Event handler called after any animations complete when the popup is opened or closed.

openOnInputClick?boolean

Whether the popup opens when clicking the input.

Defaults to true.

loopFocus?boolean

Whether to loop keyboard focus back to the input when the end of the list is reached while using the arrow keys. The first item can then be reached by pressing <kbd>ArrowDown</kbd> again from the input, or the last item can be reached by pressing <kbd>ArrowUp</kbd> from the input. The input is always included in the focus loop per [ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/). When disabled, focus does not move when on the last element and the user presses <kbd>ArrowDown</kbd>, or when on the first element and the user presses <kbd>ArrowUp</kbd>.

Defaults to true.

inputValue?string | number | readonly string[]

The input value of the combobox. Use when controlled.

defaultInputValue?string | number | readonly string[]

The uncontrolled input value when initially rendered. To render a controlled input, use the `inputValue` prop instead.

inputRef?Ref<HTMLInputElement>

A ref to the hidden input element.

filteredItems?readonly any[] | readonly Group<any>[]

Filtered items to display in the list. When provided, the list will use these items instead of filtering the `items` prop internally. Use when you want to control filtering logic externally with the `useFilter()` hook.

virtualized?boolean

Whether the items are being externally virtualized.

Defaults to false.

modal?boolean

Determines if the popup enters a modal state when open. - `true`: user interaction is limited to the popup: document page scroll is locked and pointer interactions on outside elements are disabled. - `false`: user interaction with the rest of the document is allowed.

Defaults to false.

limit?number

The maximum number of items to display in the list.

Defaults to -1.

locale?LocalesArgument

The locale to use for string comparison. Defaults to the user's runtime locale.

Combobox.Clear

Base UI

Inherited from ComboboxClearProps

disabled?boolean

Whether the component should ignore user interaction.

Defaults to false.

keepMounted?boolean

Whether the component should remain mounted in the DOM when not visible.

Defaults to false.

Inherited from NativeButtonProps

nativeButton?boolean

Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (e.g. `<div>`).

Defaults to true.

Combobox.Collection

Base UI

No additional props — forwards all standard HTML attributes to the underlying element.

Combobox.Empty

Base UI

No additional props — forwards all standard HTML attributes to the underlying element.

Combobox.Group

Base UI

Inherited from ComboboxGroupProps

items?readonly any[]

Items to be rendered within this group. When provided, child `Collection` components will use these items.

Combobox.GroupLabel

Base UI

No additional props — forwards all standard HTML attributes to the underlying element.

Combobox.Input

Base UI

Inherited from ComboboxInputProps

disabled?boolean

Whether the component should ignore user interaction.

Defaults to false.

Combobox.InputGroup

Base UI
size?"sm" | "md" | "lg" | null
intent?"neutral" | "brand" | "brand-secondary" | "accent" | "danger" | "success" | "warning" | "info" | null
emphasis?"normal" | "subtle" | null

Combobox.Item

Base UI

Inherited from ComboboxItemProps

onClick?((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)

An optional click handler for the item when selected. It fires when clicking the item with the pointer, as well as when pressing `Enter` with the keyboard if the item is highlighted when the `Input` or `List` element has focus.

index?number

The index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM.

value?any

A unique value that identifies this item.

Defaults to null.

disabled?boolean

Whether the component should ignore user interaction.

Defaults to false.

Inherited from NativeButtonProps

nativeButton?boolean

Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (e.g. `<div>`).

Defaults to true.

Combobox.ItemIndicator

Base UI

Inherited from ComboboxItemIndicatorProps

keepMounted?boolean

Whether to keep the HTML element in the DOM when the item is not selected.

Defaults to false.

Combobox.Label

Base UI

No additional props — forwards all standard HTML attributes to the underlying element.

Combobox.List

Base UI

No additional props — forwards all standard HTML attributes to the underlying element.

Combobox.Popup

Base UI

Inherited from ComboboxPopupProps

initialFocus?boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | void | HTMLElement | null)

Determines the element to focus when the popup is opened. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (first tabbable element or popup). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing.

finalFocus?boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null)

Determines the element to focus when the popup is closed. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (trigger or previously focused element). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing.

Combobox.Portal

Base UI

Inherited from ComboboxPortalProps

keepMounted?boolean

Whether to keep the portal mounted in the DOM while the popup is hidden.

Defaults to false.

Inherited from Props

container?HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null

A parent element to render the portal element into.

Combobox.Positioner

Base UI

Inherited from UseAnchorPositioningSharedParameters

anchor?any

An element to position the popup against. By default, the popup will be positioned against the trigger.

positionMethod?"absolute" | "fixed"

Determines which CSS `position` property to use.

Defaults to 'absolute'.

side?"top" | "bottom" | "left" | "right" | "inline-end" | "inline-start"

Which side of the anchor element to align the popup against. May automatically change to avoid collisions.

Defaults to 'bottom'.

sideOffset?number | OffsetFunction

Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object parameter with the following properties: - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`. - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`. - `data.side`: which side of the anchor element the positioner is aligned against. - `data.align`: how the positioner is aligned relative to the specified side. @example ```jsx <Positioner sideOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.height : anchor.width; }} /> ```

Defaults to 0.

align?"center" | "start" | "end"

How to align the popup relative to the specified side.

Defaults to 'center'.

alignOffset?number | OffsetFunction

Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object parameter with the following properties: - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`. - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`. - `data.side`: which side of the anchor element the positioner is aligned against. - `data.align`: how the positioner is aligned relative to the specified side. @example ```jsx <Positioner alignOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.width : anchor.height; }} /> ```

Defaults to 0.

collisionBoundary?any

An element or a rectangle that delimits the area that the popup is confined to.

Defaults to 'clipping-ancestors'.

collisionPadding?any

Additional space to maintain from the edge of the collision boundary.

Defaults to 5.

sticky?boolean

Whether to maintain the popup in the viewport after the anchor element was scrolled out of view.

Defaults to false.

arrowPadding?number

Minimum distance to maintain between the arrow and the edges of the popup. Use it to prevent the arrow element from hanging out of the rounded corners of a popup.

Defaults to 5.

disableAnchorTracking?boolean

Whether to disable the popup from tracking any layout shift of its positioning anchor.

Defaults to false.

collisionAvoidance?CollisionAvoidance

Determines how to handle collisions when positioning the popup. `side` controls overflow on the preferred placement axis (`top`/`bottom` or `left`/`right`): - `'flip'`: keep the requested side when it fits; otherwise try the opposite side (`top` and `bottom`, or `left` and `right`). - `'shift'`: never change side; keep the requested side and move the popup within the clipping boundary so it stays visible. - `'none'`: do not correct side-axis overflow. `align` controls overflow on the alignment axis (`start`/`center`/`end`): - `'flip'`: keep side, but swap `start` and `end` when the requested alignment overflows. - `'shift'`: keep side and requested alignment, then nudge the popup along the alignment axis to fit. - `'none'`: do not correct alignment-axis overflow. `fallbackAxisSide` controls fallback behavior on the perpendicular axis when the preferred axis cannot fit: - `'start'`: allow perpendicular fallback and try the logical start side first (`top` before `bottom`, or `left` before `right` in LTR). - `'end'`: allow perpendicular fallback and try the logical end side first (`bottom` before `top`, or `right` before `left` in LTR). - `'none'`: do not fallback to the perpendicular axis. When `side` is `'shift'`, explicitly setting `align` only supports `'shift'` or `'none'`. If `align` is omitted, it defaults to `'flip'`. @example ```jsx <Positioner collisionAvoidance={{ side: 'shift', align: 'shift', fallbackAxisSide: 'none', }} /> ```

Combobox.Status

Base UI

No additional props — forwards all standard HTML attributes to the underlying element.

Combobox.Trigger

Base UI

Inherited from ComboboxTriggerProps

disabled?boolean

Whether the component should ignore user interaction.

Defaults to false.

Inherited from NativeButtonProps

nativeButton?boolean

Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (e.g. `<div>`).

Defaults to true.