Skip to content

Combobox

Combobox

An editable combobox: a text input with a filterable listbox of Options (APG combobox with list autocomplete). Typing filters the options; ArrowDown/ArrowUp move the highlight (aria-activedescendant), Enter selects, Escape closes. Without freeform the text is only a filter: its first match becomes active while typing, and the input shows the selected option's label again when the listbox closes. With freeform the text itself is the value. Text that matches no option shows "No matches" (labels.noMatches), announced through a status region. filter replaces the match (it may keep options that do not contain the text, for a server-side search or a "Create …" entry), and query/defaultQuery/onQueryChange control the typed text (not with freeform), which resets to '' on a commit, a close, a blur, Escape, the clear button and a form reset. The expand button at the end of the input (a chevron, see expandIcon) opens and closes the list without taking focus from the input and is not a tab stop; clearable adds a clear button, a tab stop after the input. Both sit with the input in a wrapper <div> inside the root.

multiselect turns the value into an array (Fluent's selectedOptions): options draw a checkbox; Enter and a click toggle an option and keep the list open (Tab, Escape and Alt+ArrowUp close without committing), and every toggle the user makes is announced (labels.added/labels.removed, never for a controlled change, a clear or a form reset). While no text is typed the input shows the selected labels in selection order (labels.selection, values without an option left out) instead of the placeholder. Focusing the input selects them, and so does their return to the focused input (a toggle, a close, a form reset), so typing, pasting or composing text replaces them with a query that filters the options; text inserted into them queries only what was inserted, an undo or a redo back to them shows them again, and a toggle, a close or a blur clears the query. Backspace and Delete only edit the text: the options, the clear button (which clears every value) and a form reset change the value. freeform is not available with multiselect, and a non-literal multiselect={flag} is a type error: render two elements, one for each mode.

**Data mode**: items passes the options as data instead of children. The open list renders an option per matching item (renderOption draws it, an Option with the item's label by default) and the closed list none; the keys, the filter and the input's text follow the data, and each option carries aria-posinset and aria-setsize among the shown options. A long list takes a virtualWindow (from useVirtualWindow({ itemSize })): the open list then renders only the options in view, plus an overscan, with spacers for the others, every option itemSize tall; the active option stays rendered, and opening scrolls it (else the first selected option) to the middle of the list.

The <input> receives ref, id, aria-label, aria-labelledby, aria-describedby, aria-invalid, aria-required, aria-errormessage, aria-details, tabIndex, autoFocus, onFocus/onBlur/onKeyDown/onKeyUp and the text input attributes autoComplete, autoCapitalize, autoCorrect, maxLength, inputMode, spellCheck and enterKeyHint. className, style, other aria-* attributes and the remaining props stay on the root <div> (slotProps.root.ref reaches it). Inside a Field the input is labelled and described by it. It shows the error look whenever it ends up aria-invalid (its own aria-invalid or a Field error). With name/required the value takes part in form submission (one hidden input per value with multiselect), validation and reset (a multiselect reset is compared by content, so restoring the same values reports nothing). The open listbox renders in a portal; while closed it stays in the DOM, hidden.

**Size and appearance**: size resolves from its own prop, then the surrounding Field's size, then WaveProvider inputDefaults.size, else 'medium'; appearance from its own prop, then WaveProvider inputDefaults.appearance, else 'outline'; both render as data-size and data-appearance on the root <div>. The listbox keeps its size.

Sub-components: Combobox.Option, Combobox.OptionGroup. React Server Components import the flat names ComboboxOption / ComboboxOptionGroup (dotted access needs a client file).

Examples

Default

export const Default: Story = {
  args: {
    placeholder: 'Select a fruit...',
  },
  render: (args) => (
    <Combobox {...args}>
      <Option value="apple">Apple</Option>
      <Option value="banana">Banana</Option>
      <Option value="cherry">Cherry</Option>
      <Option value="grape">Grape</Option>
      <Option value="orange">Orange</Option>
    </Combobox>
  ),
};

Freeform

export const Freeform: Story = {
  args: {
    'aria-label': 'Color',
    placeholder: 'Type or select...',
    freeform: true,
  },
  render: (args) => (
    <Combobox {...args}>
      <Option value="red">Red</Option>
      <Option value="green">Green</Option>
      <Option value="blue">Blue</Option>
    </Combobox>
  ),
};

Grouped

export const Grouped: Story = {
  args: {
    'aria-label': 'Produce',
    placeholder: 'Search produce...',
  },
  render: (args) => (
    <Combobox {...args}>
      <OptionGroup label="Fruit">
        <Option value="apple">Apple</Option>
        <Option value="banana">Banana</Option>
      </OptionGroup>
      <OptionGroup label="Vegetables">
        <Option value="carrot">Carrot</Option>
        <Option value="pea" disabled>
          Pea (out of stock)
        </Option>
      </OptionGroup>
    </Combobox>
  ),
};

Clearable

export const Clearable: Story = {
  args: {
    defaultValue: 'banana',
    clearable: true,
    placeholder: 'Select a fruit...',
  },
  render: (args) => (
    <Combobox {...args}>
      <Option value="apple">Apple</Option>
      <Option value="banana">Banana</Option>
      <Option value="cherry">Cherry</Option>
    </Combobox>
  ),
};

Multiselect

export const Multiselect: StoryObj<ComboboxProps<true>> = {
  args: {
    'aria-label': undefined,
    multiselect: true,
    clearable: true,
    defaultValue: ['apple', 'cherry'],
    placeholder: 'Select fruits...',
  },
  // `freeform` is not available with `multiselect`: hide the meta's control on this story.
  argTypes: { freeform: { table: { disable: true } } },
  // The spread alone leaves `multiselect` optional (StoryObj widens `args`), which satisfies
  // neither call signature (D9): the literal attribute after it forces the multi-select one.
  render: (args) => (
    <Field label="Fruits">
      <Combobox {...args} multiselect>
        <Option value="apple">Apple</Option>
        <Option value="banana">Banana</Option>
        <Option value="cherry">Cherry</Option>
        <Option value="grape">Grape</Option>
        <Option value="orange">Orange</Option>
      </Combobox>
    </Field>
  ),
};

Custom Filter

export const CustomFilter: Story = {
  args: {
    'aria-label': 'Dessert',
    placeholder: 'Type the start of a dessert...',
  },
  render: (args) => (
    <Combobox {...args} filter={startsWithIgnoringAccents}>
      <Option value="creme-brulee">Crème brûlée</Option>
      <Option value="eclair">Éclair</Option>
      <Option value="mille-feuille">Mille-feuille</Option>
      <Option value="pain-au-chocolat">Pain au chocolat</Option>
      <Option value="tarte-tatin">Tarte Tatin</Option>
    </Combobox>
  ),
};
8 results
export const AsyncSearch: Story = {
  args: {
    'aria-label': 'Country',
    placeholder: 'Search countries...',
    onQueryChange: fn(),
  },
  render: (args) => <AsyncSearchCombobox {...args} />,
};

Without Expand Icon

export const WithoutExpandIcon: Story = {
  args: {
    expandIcon: false,
    placeholder: 'Type to search...',
  },
  render: (args) => (
    <Combobox {...args}>
      <Option value="apple">Apple</Option>
      <Option value="banana">Banana</Option>
      <Option value="cherry">Cherry</Option>
    </Combobox>
  ),
};

Disabled

export const Disabled: Story = {
  args: {
    placeholder: 'Disabled',
    disabled: true,
  },
  render: (args) => (
    <Combobox {...args}>
      <Option value="a">Alpha</Option>
    </Combobox>
  ),
};

Invalid

export const Invalid: Story = {
  args: {
    'aria-label': undefined,
    placeholder: 'Select a fruit...',
  },
  render: (args) => (
    <Field label="Fruit" error="Choose a fruit from the list." required>
      <Combobox {...args}>
        <Option value="apple">Apple</Option>
        <Option value="banana">Banana</Option>
      </Combobox>
    </Field>
  ),
};

Data Mode

export const DataMode: Story = {
  args: {
    'aria-label': 'Person',
    placeholder: 'Search 500 people...',
    defaultValue: 'person-321',
    items: PEOPLE,
  },
  argTypes: {
    items: { control: false },
    renderOption: { control: false },
    virtualWindow: { control: false },
  },
};

Ten Thousand Options

Mounted options: 0 of 10,000

export const TenThousandOptions: StoryObj<TenThousandOptionsArgs> = {
  args: {
    'aria-label': 'Person',
    placeholder: 'Search 10,000 people...',
    defaultValue: 'person-5000',
    itemSize: 32,
    style: { width: 300 },
  },
  argTypes: {
    items: { control: false },
    renderOption: { control: false },
    virtualWindow: { control: false },
    // Heights an option fits in; a smaller one would overlap the options.
    itemSize: { control: 'select', options: [32, 40, 48] },
  },
  render: (args) => <TenThousandCombobox {...args} />,
};

Ten Thousand Grouped Options

Mounted options: 0 of 10,000

export const TenThousandGroupedOptions: StoryObj<TenThousandOptionsArgs> = {
  args: {
    'aria-label': 'Person',
    placeholder: 'Search 10,000 people...',
    defaultValue: 'person-5000',
    itemSize: 32,
    style: { width: 300 },
  },
  argTypes: {
    items: { control: false },
    renderOption: { control: false },
    renderGroup: { control: false },
    virtualWindow: { control: false },
    itemSize: { control: 'select', options: [32, 40, 48] },
  },
  render: (args) => <TenThousandGroupedCombobox {...args} />,
};

Sizes And Appearances

export const SizesAndAppearances: Story = {
  render: (args) => (
    <SizeAppearanceGrid
      render={(size, appearance) => (
        <Combobox
          {...args}
          size={size}
          appearance={appearance}
          clearable
          defaultValue="apple"
          aria-label={`${size} ${appearance}`}
        >
          <Combobox.Option value="apple">Apple</Combobox.Option>
          <Combobox.Option value="banana">Banana</Combobox.Option>
        </Combobox>
      )}
    />
  ),
};

Motion

export const Motion: Story = {
  render: function MotionPopups(args) {
    return (
      <div className="flex flex-wrap gap-4">
        {motionCases(fadeAndZoom).map(({ label, motion }) => (
          <Combobox key={label} {...args} aria-label={label} motion={motion} placeholder={label}>
            <Option value="cat">Cat</Option>
            <Option value="dog">Dog</Option>
            <Option value="fish">Fish</Option>
          </Combobox>
        ))}
      </div>
    );
  },
};

Props

NameTypeRequiredDefaultDescription
multiselectbooleanNofalse

Several options can be selected (Fluent's multiselect): the value is an array, options show a checkbox, Enter and a click toggle an option and keep the list open, and each toggle is announced. While no text is typed the input shows the selected labels, selected whenever the input gains focus or they return to it, so typing replaces them with text that filters the options. Not available with freeform. A non-literal multiselect={flag} is a type error: render two elements, one for each mode.

valuereadonly string[] | stringNo

Controlled selected value ('' for none), or with multiselect the selected values (Fluent's selectedOptions).

defaultValuereadonly string[] | stringNo'' (`[]` with `multiselect`)

Initial selected value for uncontrolled usage.

onValueChange((value: string[]) => void) | ((value: string) => void)No

Called with the new value when it changes: an option is selected (toggled with multiselect, which passes a new array), or (with freeform) the text changes. Without multiselect it is not called when the current option is selected again; with it, activating a selected option deselects it, which is a change. Fluent's onOptionSelect, under WaveUI's value/onValueChange naming.

openbooleanNo

Controlled open state of the listbox. The list renders only in the browser: an open combobox is closed in the server HTML and opens once it has hydrated.

defaultOpenbooleanNofalse

Initial open state for uncontrolled usage. A combobox that starts disabled or read-only starts closed. The list renders only in the browser: it is closed in the server HTML and opens once the combobox has hydrated.

onOpenChange(open: boolean) => voidNo

Called when the listbox opens or closes.

placeholderstringNo

Placeholder text shown when no value is selected; with multiselect, whenever the input shows no selected labels (no value is selected, or no selected value has an option).

disabledbooleanNofalse

Whether the combobox is disabled and non-interactive.

size'small' | 'medium' | 'large'No

Size of the field: small (24px tall), medium (32px) or large (40px). Default: the surrounding Field's size, else WaveProvider inputDefaults.size, else 'medium'. The listbox keeps its size.

positioningPopupPositioningOptionsNo`{ matchReferenceWidth: true, fitViewport: true }`

Advanced positioning of the popup (Fluent's positioning): offset, fitViewport, matchReferenceWidth and fallbackPlacements (tried in order when the requested side has no room). The popup opens below the field.

motionMotionSlot | nullNothe fade and slide above

The popup surface's motion. By default it fades in and slides 4px away from the combobox, on the side it opened on, over 200 ms with a decelerating curve, and fades out and slides back over 100 ms with an accelerating curve (the list stays in the surface while it exits); under reduced motion it appears and disappears at once. The list does not fade out when its options changed as it closed (a filter reset by the selection), nor does the "No matches" row. null turns the motion off (the surface still renders its data-presence phases, which then end at once); a class string or { className } replaces the default classes with yours (see MotionSlot), also under a WaveProvider with motion="none", which otherwise turns the default off. Fluent's popup surfaceMotion.

appearance'outline' | 'underline' | 'filled-darker' | 'filled-lighter'No

Look of the field: outline (a full border), underline (a bottom stroke only), filled-darker or filled-lighter (a fill without a visible stroke: give the field a visible label). Default: WaveProvider inputDefaults.appearance, else 'outline'.

freeformbooleanNofalse

Whether the typed text is itself the value. Without it, typing only filters the options (the first match becomes active, so Enter selects it) and the input shows the selected option's label again when the listbox closes or loses focus. With it, the input shows typed text as typed (also when it equals an option's value), a selected option's label, and a controlled value as soon as the parent sets it (a parent that normalizes or rejects the text). Not available with multiselect (a type error there): free text cannot be one of several values.

filter(option: ListboxItem, query: string) => booleanNoa case-insensitive substring match on the option's `textValue`, else its `label`

Whether an option matches the typed text (the query, or with freeform the typed value). Called with every option that is not hidden (its value, label and textValue) and the text whenever the text is not empty; an option it returns false for is filtered out. It may keep options that do not contain the text: filter={() => true} with query and onQueryChange leaves the matching to you (a server-side search that replaces the options), and a filter that always keeps an option of your own gives a "Create …" entry. With a server-side search, keep the selected option among the children (or items), hidden while the results leave it out: a value without an option shows no label (the "Async search" story does this).

querystringNo

Controlled query: the text typed since the last commit, which filters the options. A non-empty query shows in the input (hidden while disabled or readOnly); '' shows the selected option's label (the selected labels with multiselect), except while the user edits the text, so erased text stays empty. Not used with freeform, where the typed text is the value.

defaultQuerystringNo''

Initial query for uncontrolled usage. A Combobox that starts disabled or read-only starts without it (as it starts closed). Not used with freeform.

onQueryChange(query: string) => voidNo

Called with the new query when it changes: as the user types, and with '' when it resets (a commit, a close, a blur, Escape, the clear button, a form reset, or disabled or readOnly turned on while text is typed). A Combobox that mounts disabled or read-only reports nothing: it keeps a controlled query, which shows once it unlocks. Never called with freeform.

onActiveOptionChange(value: string | null) => voidNo

Called after the active (highlighted) option changes — opening, arrow keys, the pointer, a filter change that moves it — and with null when the list closes. It reports what aria-activedescendant points at, from an effect once the change commits. Fluent's onActiveOptionChange reports neither the pointer (its options have no hover highlight) nor the close.

disabledOptionsFocusablebooleanNofalse

Keeps disabled options in the arrow-key order (the first match highlighted while typing may then be a disabled one too); they still cannot be selected (Enter and a click do nothing and the list stays open). Unlike Fluent, which always keeps disabled options reachable, WaveUI skips them by default.

namestringNo

Name of the value in form submissions (renders a hidden input; one per value with multiselect).

formstringNo

Id of the form the value belongs to, when the Combobox is outside it.

requiredbooleanNo

A value is required to submit the form (native constraint validation). Like a native readonly input, a readOnly Combobox does not block submission.

autoCompletestringNo'off'

The autocomplete attribute of the <input role="combobox">. Browser autofill is off unless you set it (for example 'on').

maxLengthnumberNo

The maximum length of the typed text (maxlength of the <input role="combobox">). With multiselect the input has no limit while it shows the selected labels, so the limit applies to the typed query only.

readOnlybooleanNo

The value cannot be changed: the input is read-only and the listbox neither opens (click, keyboard, a controlled open) nor commits; Escape is left to the page. Turning it (or disabled) on while the listbox is open closes it (onOpenChange(false)).

clearablebooleanNofalse

Shows a clear button while a value is selected (not while readOnly; while disabled it is shown disabled, as in DatePicker and TimePicker). It clears the value (onValueChange(''); every value with multiselect, onValueChange([])), drops typed text, closes the list and moves focus to the input. It is a tab stop after the input.

expandIconSlot<'span'>No

The glyph of the expand button at the end of the input (default: a chevron). The button opens and closes the list without moving focus out of the input and is not a tab stop (Alt+ArrowDown opens the list from the keyboard). null or undefined keep the chevron; false, or a value that renders nothing, hides the button. Decorative content rendered inside the built-in button: a <button> or Button passed here is not nested (its children become the glyph, with a development warning).

labelsComboboxLabelsNo

The built-in texts (the "No matches" status, the names of the clear and expand buttons and, with multiselect, the selected-labels text and the toggle announcements), for localization. Unset members keep their English defaults.

itemsreadonly ListboxItem[]No

Data mode: the options as data, in list order (value, label, and optionally textValue, disabled, hidden and group; values unique). Adjacent items with the same group are drawn as a named group under a header (renderGroup), the options of the group counting aria-posinset and aria-setsize among themselves. The open list renders one option per item that is not hidden and that the typed text matches (filter, on textValue ?? label by default; see renderOption); the closed list renders none. The keys, the selection and the input's label text follow items, also for a selected item whose option is not rendered. The children are neither read nor rendered: passing both warns once in development. Each option gets aria-posinset and aria-setsize from its place among the shown items (typing narrows them), and keeps one id per value. Without it, the options are the Option children.

renderOption(item: ListboxItem, state: ListboxOptionRenderState) => React.ReactNodeNoan `Option` with the item's `value`, `label` (also its text), `textValue` and `disabled`

Data mode: renders the option of an item, given its state (selected, active, and index among the shown options). Return an Option, or an option component of your own on useListboxOption, with the item's value (and its disabled); its position is set for you, and in a windowed list (virtualWindow) its height. It is called again only when the item, its state, its position (aria-posinset and aria-setsize, which typing changes) or the function itself changes, so pass a stable function in a long list. Ignored without items, with a development warning.

renderGroup(group: string, state: ListboxGroupRenderState) => React.ReactNodeNothe group's name, as text

Data mode: renders the header of a group of items (those with the same group, next to each other), given the group's name and its state (index among the groups, size: its shown options). Return text or a few inline elements: the header is a row of the list, not an option, so nothing in it is reachable, and it is out of the accessibility tree (aria-hidden): the group's list is named by its name. In a list with a virtualWindow the header is a row of the window (as tall as an option, or measured with measureItems) and is not sticky: it scrolls away with its group. It is called again when the group's name, index or size changes or the function itself changes. Ignored without items, with a development warning.

virtualWindowVirtualWindowNo

Data mode: renders only the options in view of a long list, plus an overscan, and spacers (aria-hidden, data-virtual-spacer) as tall as the options they stand for: pass the result of useVirtualWindow({ itemSize }), or an object of your own that implements VirtualWindow. It needs items: without them, or beside OptionGroup children, it is ignored with a development warning (a window cannot read the options of children). Items with a group are windowed with their headers, which are rows of the window (itemSize tall, or measured with measureItems) and scroll away with their group: they are not sticky.

The open popup's list is the window's scroller, so it needs no height of yours: it scrolls within its own maximum height (15rem, 240 pixels at the default root size, less where the viewport has no room). Every option is exactly itemSize tall (the list sets its height, after the option's own style), so an option's content must fit in it: the default Option with one line of text is 32 pixels tall. With a window that measures its rows (useVirtualWindow({ itemSize, measureItems: true }), itemSize being the estimate) an option has the height of its content instead, and carries the window's itemProps.

The window counts the shown options: typing narrows it, as it narrows aria-setsize. The arrow keys move over all of them; the active option stays rendered while it is scrolled away, so aria-activedescendant always names an element, and when a key (or typing) makes it active the list and the window move to it in the same update. Opening the list scrolls the active option, else the first selected one, to the middle of the list, and again once the popup's positioning has given the list its height (a short viewport) unless it was scrolled first. A closed list renders no option. The browser's scroll anchoring is off on a windowed list (the window lays the options out).

onFocusReact.FocusEventHandler<HTMLInputElement>No

Called when the <input role="combobox"> receives focus (the root keeps other handlers). With multiselect, a focus while the input shows the selected labels then selects them; event.preventDefault() skips that.

onBlurReact.FocusEventHandler<HTMLInputElement>No

Called when the <input role="combobox"> loses focus.

onKeyDownReact.KeyboardEventHandler<HTMLInputElement>No

Called on a key press in the <input role="combobox">, before the built-in listbox keys; event.preventDefault() skips them.

onKeyUpReact.KeyboardEventHandler<HTMLInputElement>No

Called when a key is released in the <input role="combobox">.

refReact.Ref<HTMLInputElement>No

Ref to the <input role="combobox">, the focusable control (Fluent UI's ref, on its primary element). The root <div> is slotProps.root.ref.

slotProps{ root?: SlotPart<'div'>; input?: SlotPart<'input'>; clearButton?: SlotPart<'button'>; expandButton?: SlotPart<'button'>; listbox?: SlotPart<'ul'>; surface?: SlotPart<'div'>; emptyMessage?: SlotPart<'div'> }No

Props for the elements the Combobox draws, by part, merged into each part's own (Fluent UI's root, input, clearIcon, expandIcon and listbox slot props): your classes after the part's (yours win a conflict), your styles over its styles, your handlers before its handlers (preventDefault() in yours skips the Combobox's handling of the event, its own on… prop included), your ref beside its ref, and your ids added to its aria-labelledby and aria-describedby. Every attribute the Combobox sets on a part is locked and keeps the Combobox's value (set it through its own props); you add the attributes it does not set. A part takes no children. The options are Options, which take their own props.

Any other prop is passed to the element it renders (HTMLDivElement).

Parts

  • root
  • input
  • clearButton
  • expandButton
  • listbox
  • surface
  • emptyMessage
  • Combobox.Option
  • Combobox.OptionGroup

Stable class names

PartClass
rootwave-combobox
inputwave-combobox__input
clearButtonwave-combobox__clear-button
expandButtonwave-combobox__expand-button
expandIconwave-combobox__expand-icon
listboxwave-combobox__listbox
surfacewave-combobox__surface
emptyMessagewave-combobox__empty-message
spacerwave-combobox__spacer