ComboBox

v1.0.0-rc.6
@ui5/webcomponents
<ui5-combobox>

Basic Example

<ui5-combobox placeholder="Enter value">
	<ui5-cb-item text="Item 1"></ui5-cb-item>
	<ui5-cb-item text="Item 2"></ui5-cb-item>
	<ui5-cb-item text="Item 3"></ui5-cb-item>
</ui5-combobox>

<ui5-combobox value-state="Success" value="Item 1">
	<ui5-cb-item text="Item 1"></ui5-cb-item>
	<ui5-cb-item text="Item 2"></ui5-cb-item>
	<ui5-cb-item text="Item 3"></ui5-cb-item>
</ui5-combobox>

<ui5-combobox value-state="Warning" value="Item 2">
	<ui5-cb-item text="Item 1"></ui5-cb-item>
	<ui5-cb-item text="Item 2"></ui5-cb-item>
	<ui5-cb-item text="Item 3"></ui5-cb-item>
</ui5-combobox>

<ui5-combobox value-state="Error" value="Item 3">
	<ui5-cb-item text="Item 1"></ui5-cb-item>
	<ui5-cb-item text="Item 2"></ui5-cb-item>
	<ui5-cb-item text="Item 3"></ui5-cb-item>
</ui5-combobox>
	

Disabled and Readonly properties

<ui5-combobox value="Disabled" disabled>
	<ui5-cb-item text="Item 1"></ui5-cb-item>
	<ui5-cb-item text="Item 2"></ui5-cb-item>
	<ui5-cb-item text="Item 3"></ui5-cb-item>
</ui5-combobox>

<ui5-combobox value="Readonly" readonly>
	<ui5-cb-item text="Item 1"></ui5-cb-item>
	<ui5-cb-item text="Item 2"></ui5-cb-item>
	<ui5-cb-item text="Item 3"></ui5-cb-item>
</ui5-combobox>
	

Filters (StartsWithPerTerm(default), StartsWith, Contains)

<ui5-combobox placeholder="Contains" filter="Contains">
	<ui5-cb-item text="Austria"></ui5-cb-item>
	<ui5-cb-item text="Bulgaria"></ui5-cb-item>
	<ui5-cb-item text="Germany"></ui5-cb-item>
	<ui5-cb-item text="United Kingdom"></ui5-cb-item>
	<ui5-cb-item text="Kazakhstan"></ui5-cb-item>
</ui5-combobox>

ComboBox with Two-Column Layout Items

<ui5-combobox placeholder="Two-column layout">
	<ui5-cb-item text="Austria" additional-text="AT"></ui5-cb-item>
	<ui5-cb-item text="Belgium" additional-text="BE"></ui5-cb-item>
	<ui5-cb-item text="Brazil" additional-text="BR"></ui5-cb-item>
	<ui5-cb-item text="Bulgaria" additional-text="BG"></ui5-cb-item>
	<ui5-cb-item text="Canada" additional-text="CA"></ui5-cb-item>
</ui5-combobox>

ComboBox with Grouping of Items

<ui5-combobox placeholder="ComboBox with grouping of suggestions">
	<ui5-cb-group-item text="A"></ui5-cb-group-item>
	<ui5-cb-item text="Argentina"></ui5-cb-item>
	<ui5-cb-item text="Australia"></ui5-cb-item>
	<ui5-cb-item text="Austria"></ui5-cb-item>	
	<ui5-cb-group-item text="B"></ui5-cb-group-item>
	<ui5-cb-item text="Bahrain"></ui5-cb-item>
	<ui5-cb-item text="Belgium"></ui5-cb-item>
	<ui5-cb-item text="Brazil"></ui5-cb-item>
	<ui5-cb-group-item text="C"></ui5-cb-group-item>
	<ui5-cb-item text="Canada"></ui5-cb-item>
	<ui5-cb-item text="Chile"></ui5-cb-item>
</ui5-combobox>

Lazy loading

<ui5-combobox placeholder="Enter value" id="lazy-cb"></ui5-combobox>

<script>
	const combo = document.getElementById("lazy-cb");

	combo.addEventListener("input", function (event) {
		while (combo.firstChild) {
			combo.removeChild(combo.firstChild);
		}

		event.target.loading = true;

		fetch("https://restcountries.eu/rest/v2/?fields=name")
			.then(function (response) {
				response.json()
					.then(function (list) {

						list.forEach(function (country) {
							const element = document.createElement("ui5-cb-item");

							element.setAttribute("text", country.name);
							combo.appendChild(element);
						});

						event.target.loading = false;

					});
			})
			.catch(function () { });
	});
</script>

Overview

The ui5-combobox component represents a drop-down menu with a list of the available options and a text input field to narrow down the options. It is commonly used to enable users to select one or more options from a predefined list.

Structure

The ui5-combobox consists of the following elements:
  • Input field - displays the selected option or a custom user entry. Users can type to narrow down the list or enter their own value.
  • Drop-down arrow - expands\collapses the option list.
  • Option list - the list of available options.

Keyboard Handling

The ui5-combobox provides advanced keyboard handling.

Picker

If the ui5-combobox is focused, you can open or close the drop-down by pressing F4, ALT+UP or ALT+DOWN keys.

ES6 Module Import

import "@ui5/webcomponents/dist/ComboBox";

Properties/Attributes

You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.

Name
Type
Default Value
Description
accessibleName
accessible-name
String
Sets the accessible aria name of the component.
since v1.0.0-rc.15
accessibleNameRef
accessible-name-ref
String
""
Receives id(or many ids) of the elements that label the combo box
since v1.0.0-rc.15
disabled
boolean
false
Defines whether the component is in disabled state.

Note: A disabled component is completely uninteractive.
filter
string
"StartsWithPerTerm"
Defines the filter type of the component. Available options are: StartsWithPerTerm, StartsWith and Contains.
loading
boolean
false
Indicates whether a loading indicator should be shown in the picker.
placeholder
string
""
Defines a short hint intended to aid the user with data entry when the component has no value.
readonly
boolean
false
Defines whether the component is readonly.

Note: A read-only component is not editable, but still provides visual feedback upon user interaction.
required
boolean
false
Defines whether the component is required.
value
string
""
Defines the value of the component.
valueState
value-state
ValueState
"None"
Defines the value state of the component.

Available options are:
  • None
  • Error
  • Warning
  • Success
  • Information

Slots

This Element provides slot(s). This means it can display its child nodes.
Unless targeting the default slot, use the slot attribute to define the destination slot for each child.
Text, along with HTML Elements with no slot attribute, goes the the default slot.

Slot
Type
Description
default
HTMLElement [0..n]
Defines the component items.
icon
HTMLElement
Defines the icon to be displayed in the input field.
valueStateMessage
HTMLElement [0..n]
Defines the value state message that will be displayed as pop up under the component.

Note: If not specified, a default text (in the respective language) will be displayed.
Note: The valueStateMessage would be displayed, when the ui5-select is in Information, Warning or Error value state.

Events

This Web Component fires semantic events upon user interaction. You can bind to these events with the standard DOM APIs, such as addEventListener.

Name
Description
change
Fired when the input operation has finished by pressing Enter, focusout or an item is selected.
input
Fired when typing in input.

Note: filterValue property is updated, input is changed.
selection-change
Fired when selection is changed by user interaction
item
type: HTMLElement
description: item to be selected.

ComboBoxItem

The ui5-cb-item represents the item for a ui5-combobox.

Properties/Attributes

You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.

Name
Type
Default Value
Description
additionalText
additional-text
string
""
Defines the additional text of the component.
since v1.0.0-rc.11
text
string
""
Defines the text of the component.

ComboBoxGroupItem

The ui5-combobox-group-item is type of suggestion item, that can be used to split the ui5-combobox suggestions into groups.

Properties/Attributes

You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.

Name
Type
Default Value
Description
text
string
""
Defines the text of the component.
Theme: Quartz Light Quartz Dark Quartz High Contrast Black Quartz High Contrast White Belize High Contrast Black High Contrast White
Content Density: Cozy Compact
Text Direction: LTR RTL
Apply Cancel