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

ComboboxThis component
Most often used when the workflow requires multiple selections.
Best when the number of selectable items is finite and small.
Often used for accepting custom values and both single and multiple selection.
AutocompleteAlternative
Most often used with very long or unpredictable lengths of items.
Best for programmatically returning responses based on user input.
Does not accept custom values or multiple selections.

Accessibility

Keyboard navigation

KeyFunction
BackspaceWhen the component is focused and contains a selected calcite-combobox-item will remove the most recently added from the component.
SpaceIf the component is not open, opens the component.
Arrow upOnce 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 downOnce 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.
EnterIf the component is open and a calcite-combobox-item is active, will toggle it's selected state.
EscIf the component is open, closes the component.
TabMoves focus in and out of the component.
Tab and ShiftMoves focus in and out of the component.

API reference

Properties

PropertyAttributeDescriptionTypeDefault
allowCustomValuesallow-custom-values

When true, allows entry of custom values, which are not in the original set of items.

booleanfalse
clearDisabledclear-disabled

When true, disables value-clearing.

booleanfalse
disableddisabled

When true, prevents interaction and decreases the component's opacity.

booleanfalse
filteredItemsread-only

The component's filtered items.

HTMLCalciteComboboxItemElement[]
filterProps

Specifies the properties to match against when filtering. If not set, all properties will be matched (description, label, metadata, shortHeading).

string[]
filterTextfilter-text

The component's filter input field text.

string
flipPlacements

Specifies the component's fallback placement for slotted content when it's initial or specified placement has insufficient space available.

FlipPlacement[]
formform

Specifies the id of the component's associated form.

When not set, the component is associated with its ancestor form element, if one exists.

string
labelrequiredlabel

Specifies an accessible label for the component.

string
labelTextlabel-text

Specifies the component's label text.

string
maxItemsmax-items

Specifies the maximum number of calcite-combobox-item-groups & calcite-combobox-items (including nested children) to display before displaying a scrollbar.

number0
messageOverrides

Overrides individual strings used by the component.

Record<string, unknown> | undefined
namename

Specifies the name of the component. Required to pass the component's value on form submission.

string
openopen

When true, displays and positions the component.

booleanfalse
overlayPositioningoverlay-positioning

Specifies the type of positioning to use for overlaid content, where:

"absolute" works for most cases - positioning the component inside of overflowing parent containers, which affects the container's layout, and

"fixed" is used to escape an overflowing parent container, or when the reference element's position CSS property is "fixed".

OverlayPositioning"absolute"
placeholderplaceholder

Specifies the input's placeholder text.

string
placeholderIconplaceholder-icon

Specifies the input's placeholder icon.

IconName
placeholderIconFlipRtlplaceholder-icon-flip-rtl

When true and the element direction is right-to-left ("rtl"), flips the input's placeholderIcon.

booleanfalse
placementplacement

Specifies the component's position relative to the referenceElement.

LogicalPlacement"bottom-start"
readOnlyread-only

When true, the component's value can be read, but controls are not accessible and the value cannot be modified.

booleanfalse
requiredrequired

When true and the component resides in a form, the component must have a value in order for the form to submit.

booleanfalse
scalescale

Specifies the size of the component.

Scale"m"
selectAllEnabledselect-all-enabled

When true and selectionMode is "multiple" or "ancestors", displays a checkbox for selecting all calcite-combobox-items.

booleanfalse
selectedItemsread-only

The component's selected items.

HTMLCalciteComboboxItemElement[]
selectionAppearanceselection-appearance

Specifies the selection appearance, where

"icon" displays a checkmark or dot, and

"highlight" displays a background highlight.

Extract<"icon" | "highlight", SelectionAppearance>"icon"
selectionDisplayselection-display

When selectionMode is "ancestors" or "multiple", specifies the display of multiple calcite-combobox-item selections, where:

"all" displays all selections with individual calcite-chips,

"fit" displays individual calcite-chips that scale to the component's size, including a non-closable calcite-chip, which provides the number of additional calcite-combobox-item selections not visually displayed, and

"single" displays one calcite-chip with the total number of selections.

SelectionDisplay"all"
selectionModeselection-mode

Specifies the selection mode of the component, where:

"multiple" allows any number of selections,

"single" allows only one selection,

"single-persist" allows one selection and prevents de-selection, and

"ancestors" allows multiple selections, but shows ancestors of selected items as selected, with only deepest children shown in chips.

Extract<"single" | "single-persist" | "ancestors" | "multiple", SelectionMode>"multiple"
statusstatus

Specifies the input field's status, which determines message and icons.

Status"idle"
topLayerDisabledtop-layer-disabled

When true and the component is open, disables top layer placement.

Only set this if you need complex z-index control or if top layer placement causes conflicts with third-party components.

booleanfalse
validationIconvalidation-icon

Specifies the validation icon to display under the component.

IconName | boolean
validationMessagevalidation-message

Specifies the validation message to display under the component.

string
validityread-only

The component's current validation state.

ValidityState
valuevalue

The component's value(s) from the selected calcite-combobox-item(s).

string | string[]

Slots

NameDescription
default (unnamed)

A slot for adding calcite-combobox-items.

label-content

A slot for rendering content next to the component's labelText.

Styles

NameDescription
--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 selectionDisplay is "single", specifies the text color of the component's input.

Events

NameDescriptionBehavior
calciteComboboxBeforeClose

Fires when the component is requested to be closed, and before the closing transition begins.

bubblescomposed
calciteComboboxBeforeOpen

Fires when the component is added to the DOM but not rendered, and before the opening transition begins.

bubblescomposed
calciteComboboxChange

Fires when the selected item(s) changes.

bubblescomposed
calciteComboboxChipClose

Fires when a selected item in the component is closed via its calcite-chip.

bubblescomposed
calciteComboboxClose

Fires when the component is closed and animation is complete.

bubblescomposed
calciteComboboxFilterChange

Fires when text is added to filter the options list.

bubblescomposed
calciteComboboxOpen

Fires when the component is open and animation is complete.

bubblescomposed

Methods

NameDescriptionSignature
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>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.