Combobox is an input and dropdown-based selection, which allows for quick filtering of single and multi-selections.
Overview
Combobox is designed for situations where a dropdown or list has a large amount of choices to sift through. The type-ahead property of Combobox allows the user to quickly type and search for available selections.
Multi-select Combobox utilizes Chips to display selected items, which can quickly be deleted by selecting the "Closable" icon or pressing the Backspace key when focused.
Sample
Usage
- Multi-select purposes
- Filtering
Component comparison
Accessibility
Keyboard navigation
| Key | Function |
|---|---|
Backspace | When the component is focused and contains a selected calcite-combobox-item will remove the most recently added from the component. |
Space | If the component is not open, opens the component. |
Arrow up | Once the component is open and in focus, moves focus to previous calcite-combobox-item. If the current focus is the first calcite-combobox-item, focus will cycle to the last calcite-combobox-item. |
Arrow down | Once the component is open and in focus, move focus to next calcite-combobox-item. If the current focus is the last calcite-combobox-item, focus will cycle to the first calcite-combobox-item. |
Enter | If the component is open and a calcite-combobox-item is active, will toggle it's selected state. |
Esc | If the component is open, closes the component. |
Tab | Moves focus in and out of the component. |
Tab and Shift | Moves focus in and out of the component. |
API reference
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
| allowCustomValues | allow-custom-values | When | boolean | false |
| clearDisabled | clear-disabled | When | boolean | false |
| disabled | disabled | When | boolean | false |
| filteredItems | The component's filtered items. | HTMLCalciteComboboxItemElement[] | ||
| filterProps | Specifies the properties to match against when filtering. If not set, all properties will be matched ( | string[] | ||
| filterText | filter-text | The component's filter input field text. | string | |
| flipPlacements | Specifies the component's fallback | FlipPlacement[] | ||
| form | form | Specifies the When not set, the component is associated with its ancestor form element, if one exists. | string | |
| label | label | Specifies an accessible label for the component. | string | |
| labelText | label-text | Specifies the component's label text. | string | |
| maxItems | max-items | Specifies the maximum number of | number | 0 |
| messageOverrides | Overrides individual strings used by the component. | Record<string, unknown> | undefined | ||
| name | name | Specifies the name of the component. Required to pass the component's | string | |
| open | open | When | boolean | false |
| overlayPositioning | overlay-positioning | Specifies the type of positioning to use for overlaid content, where:
| OverlayPositioning | "absolute" |
| placeholder | placeholder | Specifies the input's placeholder text. | string | |
| placeholderIcon | placeholder-icon | Specifies the input's placeholder icon. | IconName | |
| placeholderIconFlipRtl | placeholder-icon-flip-rtl | When | boolean | false |
| placement | placement | Specifies the component's position relative to the | LogicalPlacement | "bottom-start" |
| readOnly | read-only | When | boolean | false |
| required | required | When | boolean | false |
| scale | scale | Specifies the size of the component. | Scale | "m" |
| selectAllEnabled | select-all-enabled | When | boolean | false |
| selectedItems | The component's selected items. | HTMLCalciteComboboxItemElement[] | ||
| selectionAppearance | selection-appearance | Specifies the selection appearance, where
| Extract<"icon" | "highlight", SelectionAppearance> | "icon" |
| selectionDisplay | selection-display | When
| SelectionDisplay | "all" |
| selectionMode | selection-mode | Specifies the selection mode of the component, where:
| Extract<"single" | "single-persist" | "ancestors" | "multiple", SelectionMode> | "multiple" |
| status | status | Specifies the input field's status, which determines message and icons. | Status | "idle" |
| topLayerDisabled | top-layer-disabled | When Only set this if you need complex z-index control or if top layer placement causes conflicts with third-party components. | boolean | false |
| validationIcon | validation-icon | Specifies the validation icon to display under the component. | IconName | boolean | |
| validationMessage | validation-message | Specifies the validation message to display under the component. | string | |
| validity | The component's current validation state. | ValidityState | ||
| value | value | The component's value(s) from the selected | string | string[] |
Slots
| Name | Description |
|---|---|
| default (unnamed) | A slot for adding |
| label-content | A slot for rendering content next to the component's |
Styles
| Name | Description |
|---|---|
| --calcite-combobox-divider-color | Specifies the component's divider color. |
| --calcite-combobox-icon-color | Specifies the component's icon color. |
| --calcite-combobox-icon-color-hover | Specifies the component's icon color when hovered. |
| --calcite-combobox-background-color | Specifies the background color of the component's listbox. |
| --calcite-combobox-input-border-color | Specifies the border color of the component's input. |
| --calcite-combobox-input-background-color | Specifies the background color of the component's input. |
| --calcite-combobox-input-height | Specifies the height of the component's input. |
| --calcite-combobox-input-text-color | When |
Events
| Name | Description | Behavior |
|---|---|---|
| calciteComboboxBeforeClose | Fires when the component is requested to be closed, and before the closing transition begins. | |
| calciteComboboxBeforeOpen | Fires when the component is added to the DOM but not rendered, and before the opening transition begins. | |
| calciteComboboxChange | Fires when the selected item(s) changes. | |
| calciteComboboxChipClose | Fires when a selected item in the component is closed via its | |
| calciteComboboxClose | Fires when the component is closed and animation is complete. | |
| calciteComboboxFilterChange | Fires when text is added to filter the options list. | |
| calciteComboboxOpen | Fires when the component is open and animation is complete. |
Methods
| Name | Description | Signature |
|---|---|---|
| componentOnReady | Creates a promise that resolves once the component is fully loaded. | componentOnReady(): Promise<this> |
| reposition | Updates the component's position. | reposition(delayed?: boolean): Promise<void> |
| setFocus | Sets focus on the component. | setFocus(options?: FocusOptions): Promise<void> |