Skip to main content

Combo Box

Combo Box lets users choose one or more items from an options menu.

Use a Combo Box to offer a list of choices where multiple selection is possible.

Example

Live Editor
Result
Loading...

Usage Rules

When to use: Combo Box vs. List of Checkboxes vs. Select

The Combo Box component has feature parity with the Select component, and yet behaves slightly differently and offers many additional, but optional features. In general when both components could be used, make a decision based on the following criteria:

  • If the options needs to be cleared after being selected, use the Combo Box component. Do not "hack" the Select component to clear the options by adding a "None Selected" option to the option list.
  • Avoid mixing these two components in a composition (eg. filter toolbar), as that could lead to user confusion.

When it comes to the simple use case of selecting one or more options from a list (without additional features like creating option or searching within that list), follow this decision tree:

Select

  • Users can select only one value from a list of mutually exclusive options.
  • There are 5–15 options.

Checkbox List

  • There’s a small number of options (5 or fewer) from which users can choose.
  • There are 5–15 options.
  • Seeing the selected item is more important than viewing the other available options.
  • Space is not limited, or the list could be wrapped by a scroll container.

Radio Group

  • Users can select only one value from a list of mutually exclusive options.
  • There’s a small number of options (5 or fewer) from which users can choose.

Combo Box

  • There are 5–15 options.
  • There are more than 15 options.
  • Users can select one or many from the list of options.
  • Seeing an overview of all items, selected or not, aids in task completion.
  • There’s not a clear or optimal default option.
  • The list of options needs to be searchable.
  • The user needs to be able to add new options.

Variants

Adaptive Width

If you would like to have the width of ComboBox adaptive to text, use the boolean prop adaptiveWidth

Live Editor
Result
Loading...

Adaptive Width with min-width for Options

If you are using adaptiveWidth prop and would like to give the options a minimum width, you can use optionsMinWidth

Live Editor
Result
Loading...

Async

Use the async kind to load options from a remote data source as the user types.

Live Editor
Result
Loading...

Async Creatable

The async-creatable kind supports loading options from a remote data source and creating new options.

Live Editor
Result
Loading...

BlockScroll

You can block/unblock the scrolling when the ComboBox is open by using blockScroll, default false.

Live Editor
Result
Loading...

Clearable

Use isClearable boolean prop to clear the selected option(s), you can also use onClear callback event when value is cleared.

Live Editor
Result
Loading...

Creatable

The creatable kind let users add new options along with the existing ones.

Live Editor
Result
Loading...

Custom Labelled Status Indicating Input

We can use indicatorCustomLabels props which needs to match the StatusIndicatorLabelTypes exported from StatusIndicator component to show custom labels, when no custom labels are passed, default props are used.

Live Editor
Result
Loading...

Custom dataTestId

You can now test the component using custom testid using dataTestId component.

Live Editor
Result
Loading...

Custom filter

You can customize the filter to search the options by adding the prop customFilterOption to the component.

Live Editor
Result
Loading...

Description

You can add description to the option using description prop for items.

Live Editor
Result
Loading...

Disabled

Live Editor
Result
Loading...

Disabled Option

You can disable an option by setting the isDisabled property to true.

Live Editor
Result
Loading...

FormatOptionLabel

You can customize the options by using formatOptionLabel and returning ReactNode

Live Editor
Result
Loading...

Free-text input with autocomplete

Use kind="input" property to allow users type any kind of text even when it's not listed in the options. Such behavior is useful when you need a search-like input with autocomplete capabilities.

info

ComboBox component with kind="input" does not support multiple and noOptionsMessage properties.

Live Editor
Result
Loading...

Group Label Normalization

We have a boolean prop groupLabelNormalize to Normalize the label casing of the group labels.

Live Editor
Result
Loading...

Icons

We support Icons with platform icons to the options menu

You can add the AppIcon by using the prop appInfo which is an object that has two keys appId and appName.

We also support DuoTone icons as prop iconName.

Finally the platform icons can be added by using the prop platform that accepts a array of iconNames.

Live Editor
Result
Loading...

Loading State

You can add a spinner to ComboBox by adding isLoading prop

Live Editor
Result
Loading...

Label and Info Text

Use an info text to give specific instructions to help users correctly fill in the data. You can also use it to clarify how the data will be used.

Live Editor
Result
Loading...

In cases when ComboBox is used in constrained spaces, it is possible to specify maxMenuHeight for the options box.

Live Editor
Result
Loading...

You can manage the placement of the dropdown by using menuPlacement.

Has 3 variants: auto, bottom and top and which is default to auto.

Live Editor
Result
Loading...

Multi Creatable

The multi-creatable kind supports creating new multiple values.

Live Editor
Result
Loading...

Multi Selection

You can provide multiple prop to enable multiple selection.

You also can do the range selection with Shift key, by selecting an option first then press and hold the Shift to select the range.

Live Editor
Result
Loading...

Multi Selection with Select All Option

You can provide select all options by using selectAll prop with custom label. It's an optional prop to allow display Select All Option.

Live Editor
Result
Loading...

Multi Selection with limiter banner

You can provide multiLimit prop to enable multiple selection with the limited selected options which can be displayed. The rest of selected options will be displayed as limiter banner.

Live Editor
Result
Loading...

You can also provide multiLimit prop as 'zero' to show only limiter banner.

Where first limiter banner will be displayed as value of selected.

Live Editor
Result
Loading...

Open Programmatically

You can use the isOpenDefault prop to load the component open and the isOpen prop to open the component programmatically. Please, remember in this case it will stay open until you change isOpen to false.

note

Opening the ComboBox with either of these props set to true will not block scroll on the page.

Live Editor
Result
Loading...

Optional Text

You can show the field as optional or custom text by using the optionalText prop as string.

Live Editor
Result
Loading...

You can add extra piece of information to the label by including a tooltip.

Live Editor
Result
Loading...

You can change the position of the info text to be on top of the ComboBox.

warning

Please avoid using the Info Text on top of the ComboBox when you also need the optional label.

Live Editor
Result
Loading...

We also support text tags inside the Info Text. Like strong, b, i and a.

Live Editor
Result
Loading...

Readonly

ComboBox component supports readOnly property which can be used to prevent password managers from auto-filling internal's input element.

Live Editor
Result
Loading...

Readonly options

You can use readonly property in ComboBox options to specify options that cannot be deleted or removed

Live Editor
Result
Loading...

Status Indicating

Live Editor
Result
Loading...

ComboBox component's Status Indicator withLabel, here you can see defaultLabels for indicatorType.

defaultLabels: {
progress: 'Saving…',
positive: 'Saved!',
negative: 'Disconnected!'
}
Live Editor
Result
Loading...

Searchable ComboBox

Set the prop isSearchable as false to disable this feature on the ComboBox, as this option is enabled by default.

Live Editor
Result
Loading...

Tabs Options

This allows to use Tabs inside ComboBox

Live Editor
Result
Loading...

Tooltip on ComboBox options

To add Tooltip to an option you can add tooltipText to your options object. There are 3 props you can alter on the comboBox tooltip: delay: true, position: 'right' and offset: [0, 10]. To alter these values you can add the prop optionsTooltipProps which takes an object, ie: optionsTooltipProps={{position: 'left'}}.

Use the formatSelectedOption on the ComboBox to customize the content of the tooltip shown when you hover on the selected option.

formatSelectedOption is passed the selected option and should return a ReactNode.

Live Editor
Result
Loading...

Truncate tokens

The prop truncateTokens is a boolean to truncate the multi-value-chips in ComboBox multi-selection.

Live Editor
Result
Loading...

Virtualization

This component supports virtualization for the list of options. This improves rendering performance when handling large amounts of data.

note

We have tested that this component works with up to 100.000 items, with a minor delay when rendering the larger numbers. If you require a longer list of options, please consider using a different approach.

Live Editor
Result
Loading...

Examples

Multi-creatable

Example for onBlur prop on multi-creatable kind of ComboBox

Live Editor
Result
Loading...

Multi-creatable with Multi-selection

Live Editor
Result
Loading...

Props

ComboBox

NameTypeDefault
kind
The kind of the combo box
"input" | "creatable" | "async" | "async-creatable" | "multi-creatable"
noOptionsMessage
Function that returns text to display when there are no options
((data: { inputValue: string; }) => string | null)
multiple
Use this prop to allow multiple selection
boolean
label
The label of the combo box
string
value
The value of the select. Reflected by the selected option.
Option | OptionType[] | null
indicatorType
The prop for indicatorType which is required to enable the indicator and shows the status based on its given type without label.
"negative" | "positive" | "warning" | "progress"
indicatorWithLabel
This prop enables the display of a label next the status indicator. If no custom label is passed, it uses the default labels.
boolean
indicatorCustomLabels
The prop for status indicator with custom labels with StatusIndicatorLabelTypes, if not passed uses default props that can be exported from StatusIndicator component.
StatusIndicatorLabelTypes
options
Array of options, Array of group options, and Object of tab options, that populate the select menu. The option has two required properties {label: string, value: string}. It can be extended with any additional properties.
OptionType[] | GroupBase<OptionType>[] | Record<string, OptionType[] | GroupBase<OptionType>[]>
labelIconTooltip
The labelIconTooltip content can either be pure text or any rich content wrapped in a React component The labelIconTooltip content will be shown when hovering the label icon. The labelIconTooltip position is used to define the positioning of the tooltip When the labelIconTooltip content is not provided, the label icon will be not shown.
Omit<TooltipProps, "children">
loadOptions
Function that returns a promise, which is the set of options to be used once the promise resolves
((inputValue: string) => Promise<OptionType[]>)
onClear
onClear callback event which triggers when combobox is cleared
(() => void)
onChange
Handle change events when selecting an option. The first argument is a new value. The second argument is an object containing info about the change event. For example, name of the action (select-option) and the selected option.
((value: OptionType | OnChangeValue<OptionType, MultiType>, action?: ActionMeta<OptionType>) => void) | ((value: OptionType, action?: ActionMeta<...>) => void) | undefined
inputValue
Current input value
string
onInputChange
Handle change events on the input. The first argument is a new value. The second argument is an object containing info about the change event. For example, name of the action (select-option) and the selected option.
((newValue: string, actionMeta: InputActionMeta) => void)
onKeyDown
Handle the keyboard enter event. The argument is a keyboard event.
KeyboardEventHandler<HTMLDivElement>
onBlur
Handle blur events on the control. The argument is the event.
FocusEventHandler
onFocus
Handle focus events on the control. The argument is the event.
FocusEventHandler
onCreateOption
If provided, this will be called with the input value when a new option is created, and onChange will not be called. Use this when you need more control over what happens when new options are created.
((inputValue: string) => void)
loadingMessage
Function that returns text to display when loading options
((data: { inputValue: string; }) => string | null)
formatCreateOptionLabel
Function that returns text to display in the create option
((inputValue: string) => string)
isLoading
Boolean prop to show spinner in ComboBox
boolean
infoText
Instructions to help users correctly fill in the data
string
infoTextTop
positions the infoText on top of the ComboBox
boolean
invalid
Visually notify the user that the provided value is invalid
boolean
disabled
Use this prop if the component should not be interactive
boolean
id
Native HTML attribute: Link . Internally, this component uses a random id. We use it to associate an input with a label element. As the random id might break snapshot tests it can be overridden by setting an explicit id.
string
name
Native HTML attribute: Link
string
placeholder
This text is shown when no item is selected
string
aria-label
Provide at least one label(visual or non-visual) property for better accessibility. Check Accessibility page for more info: Link
string
aria-labelledby
Provide at least one label(visual or non-visual) property for better accessibility. Check Accessibility page for more info: Link
string
isOpen
Controls if the comboBox is open or closed
boolean
isOpenDefault
Loads the comboBox open
boolean
isSearchable
enables search functionality
boolean
optionsTooltipProps
enables tooltip message over options
OptionsTooltipProps
multiLimit
Limit for MultiSelect
number | "zero"
adaptiveWidth
Boolean value for ComboBox adaptive width
boolean
optionsMinWidth
String or number value for ComboBox options min width
string | number
formatOptionLabel
Formats option labels in the menu and control as React components
((option: OptionType, labelMeta: FormatOptionLabelMeta<OptionType>) => ReactNode)
formatSelectedOption
Customizes tooltip content shown when you hover on the selected option
((option: OptionType) => ReactNode)
tabItems
Array of tab items. See the structure of TabItemType
TabItemType[]
initialSelectedTab
initial tabId of selected tab item
string
autoFocus
Focus the control when it is mounted: Link
boolean
menuPlacement
Placement prop for dropdown
"auto" | "top" | "bottom"
blockScroll
The prop allows controlling the placement of the dropdown.
boolean
optionalText
optionalText value to show the field is optional with custom text
string
readOnly
Native HTML attribute: Link
boolean
isClearable
Boolean prop to show the ClearIndicator
boolean
selectAll
The prop allows to display Select All option with custom label.
SelectAllType
dataTestId
Data-testid for the component
string
truncateTokens
Boolean to truncate the multi value chips
boolean
customFilterOption
Function to customize search
((option: FilterOptionOption<Option>, inputValue: string) => boolean) | null
groupLabelNormalize
Boolean to set Grouplabel lowercase
boolean
maxMenuHeight
Defines max-height for the menu list
number
css
Add custom styles to this component. Use with caution. Learn more here: Link
SupportedStyleAttributes
inputFieldCss
SupportedStyleAttributes
data-{foo}
Data attributes can be used by testing libraries to retrieve components or assert their existence
string
* - the prop is required.