Skip to content

Combobox

A Combobox combines a text input with an icon-only chevron button. When activated, a dropdown menu of selectable options displays.

Guidelines

When to use comboboxes

Through comboboxes, users can input text, numbers, symbols or mixed-format strings (unless specifically restricted) while being offered autocomplete options in a dropdown menu.

Use the Combobox component when it's difficult to predict the user's response to a prompt. It provides predefined input values as options, for example common responses, to ease filling out the input with relevant values.

Specifications

Specification of Combobox.

  1. Icon (optional)
    Icons may be added to simplify the identification of specific combobox inputs.
  2. Placeholder text (optional)
    The placeholder text provides an example of what type of information is being requested in the input. The placeholder text should further illustrate and support the combobox input label. However, it should never be the only input description.
  3. Chevron button
    An icon-only chevron button opens the menu.
  4. Menu
    When the combobox is active, a menu with options is displayed.

Component limitations

The base min-width for the Combobox component is set at @size-1600 (equivalent to 256px in the default Codex theme), but it can be customized to a smaller width if needed. There is no maximum width limit.

If the text in the Combobox component exceeds the available space, it will overflow horizontally.

By default, when the menu is expanded, all menu items are displayed. However, if the menu height is limited, the remaining menu items will be accessible via scrolling.

Refer to the Combobox component in Codex Figma.

Interaction states

Comboboxes have the following visually separate states:

States of the Combobox component: default, hover on input, hover on button, disabled, active, filled, and no results.

  1. Default
  2. Hover on input
  3. Hover on button
  4. Disabled
  5. Active and hover on one of the menu items
  6. Typing in the input and having a menu item selected based on the matching text
  7. Combobox filled with one selected menu option
  8. Active with no results

Best practices

Consider the following recommendations when using comboboxes.

Icon

Combobox with a complex icon.

Do:
  • Use a start icon that complements the placeholder text.

Combobox with a search icon.

Don't:
  • Use icons that are difficult to understand or do not clearly convey their purpose.

Keyboard navigation

KeyFunction
TabIt places the focus within the input of the Combobox and opens its menu. It also moves the focus to the next interactive element in tab order.
Shift + TabWhen the focus is placed within the Combobox input, it moves the focus to the previous interactive element.
Down arrowWhen the Combobox is focused, it opens the menu. When the menu is open, it navigates through menu options. If pressed at the last visible option, it scrolls to the next "hidden" menu item.
Up arrowWhen the Combobox is focused, it opens the menu. When the menu is open, it navigates through menu options.
EnterIt opens the menu when the focus is placed on the Combobox. If the menu is open, it closes the menu. If the focus is placed in any of the options within the menu, the focused option is selected.
EscWhen the menu it’s open, it closes the menu.
HomeOptionally, it moves the focus to the first option. Optionally, in a single-select listbox, selection may also move with focus. Supporting this key is strongly recommended for lists with more than five options.
EndOptionally, it moves the focus to the last option. Optionally, in a single-select listbox, selection may also move with focus. Supporting this key is strongly recommended for lists with more than five options.

Demos

Basic Usage

The Combobox component combines a menu of selectable items with a text box that can accept arbitrary input from the user. The component should receive a v-model:selected binding from its parent as well as an array of menu items (which can be empty).

Selected value:

NameValue
View
Reading direction

Clearable, with start icon

Valid TextInput props like startIcon, endIcon, and clearable will be passed on to the embedded TextInput.

Selected value:

With menu item icons and descriptions

Items are displayed via the MenuItem component—see the MenuItem docs for more options. In this example, a menuConfig object is passed to the Combobox to bold the label text and hide the text overflow of the descriptions.

With custom menu item display

Like other menu-style components (Select, Lookup, etc.), a custom template can be provided via the #menu-item slot. In this example, only the menu item's icon is displayed in the menu.

With "no results" content

A non-interactive "no results" message can be displayed via the no-results slot. If populated, this slot will automatically display when there are zero menu items.

With configurable scroll

By default, all menu items are displayed when the menu is expanded. To limit the height of the menu and enable scrolling, use the visibleItemLimit property of the menuConfig prop.

Disabled

Form field

A Combobox can be wrapped in the Field component to add features like a semantic label, description and help text, validation messages, and more. See the Field page for more information.

What kind of data does the function accept?
Choose a type from the menu or enter a custom type.

Vue usage

TextInput props apply

This component contains a TextInput component. You can bind TextInput props to this component and they will be passed to the TextInput within.

Attributes passed to input

This component will pass any HTML attributes applied to it, except for CSS class, to the <input> element within the component.

Props

Prop nameDescriptionTypeDefault
menuItems(required)Menu items. See the MenuItemData type.MenuItemData[]
selected(required)Value of the current selection.

Must be bound with v-model:selected.
string|number
disabledWhether the dropdown is disabled.booleanfalse
menuConfigConfiguration for various menu features. All properties default to false.

See the MenuConfig type.
MenuConfig() => { return {} as MenuConfig; }
statusstatus property of the TextInput componentValidationStatusType'default'

Events

Event namePropertiesDescription
inputevent InputEventWhen the input value changes via direct use of the input
changeevent EventWhen an input value change is committed by the user (e.g. on blur)
load-moreWhen the user scrolls towards the bottom of the menu.

If it is possible to add or load more menu items, then now would be a good moment so that the user can experience infinite scrolling.
update:selectedselected string|number - The new selected valueWhen the selected value changes.
focusevent FocusEventWhen the input comes into focus
blurevent FocusEventWhen the input loses focus

Slots

NameDescriptionBindings
menu-itemDisplay of an individual item in the menumenu-item MenuItemData - The current menu item
no-resultsMessage to show if there are no menu items to display.