Skip to content

Combobox

A filterable single-select combobox whose input is the control: an always-visible editable input shows the selected label, typing filters options in real time, and value takes option.value on selection.

Positioning vs. Select and AutoComplete

  • Select: button-triggered dropdown, the value is limited to options, no always-visible input;
  • AutoComplete: free-text suggestion, the value can be any typed content (not necessarily from options);
  • Combobox: the input is the control, typing is only for filtering, the value must come from an option (option.value).

Basic Usage

Basic usage

Click/focus to open the dropdown; typing filters in real time (filterable is enabled by default, substring-matching the label); / move the highlight, Enter selects, Esc closes.

Preset Value (controlled)

Preset value (controlled)

value is a controlled property: it is written back after selection; externally changing the property also immediately reflects in the input's label.

Externally Controlled Value

External controlled value

Set to AppleClear value

In controlled mode, the host can drive the component display via the value attribute at any time:

Filtering & Blur Boundaries

Input filtering + blur fallback

If you type without selecting and then blur/press Esc, the input falls back to the currently selected label (non-destructive by default — the selected value is not lost).

Not Filterable

Filtering disabled (filterable="false")

With filterable="false", typing no longer filters options; select only via keyboard / + Enter or mouse.

Clearable

Clearable

When a value is selected, a clear button appears; clicking clears value and dispatches oas-clear and oas-change.

Loading

Loading

While loading, the dropdown shows a "加载中…" placeholder (the host sets it during remote data requests).

Empty State

No options (empty)

When options are empty, the dropdown shows "暂无选项"; when filtering yields no match, "无匹配选项" is shown.

Disabled

Disabled

Events

Event output

Listen to oas-input (filter keyword), oas-change (selection), oas-clear (clear):

API

Attributes

AttributeDescriptionTypeDefault
clearableClearable (shows a clear button when a value exists; clearing dispatches oas-clear)boolean
disabledDisabled (no input, no dropdown)boolean
filterableFilter labels in real time while typing (filterable="false" disables local filtering)stringtrue
loadingLoading placeholder (dropdown shows "加载中…")boolean
optionsOptions, JSON array [{ label, value, disabled? }]Option[] | string[]
placeholderPlaceholder text
valueCurrent value (controlled, the selected option's option.value)string

Events

EventDescription
oas-changeSelection/clear change, detail: { value }
oas-clearClear button clicked, detail: { value } (value before clearing)
oas-inputFilter keyword typed, detail: { value }

Keyboard: Enter / focus to open, / to move the highlight, Enter to select, Esc to close and revert.