Skip to content
🌏 Translated with the assistance of DeepSeek and ChatGPT

Auto Complete

A text input field with suggestions.

Basic Usage

Pass options as the list of choices. Provide modelValue for controlled mode.
Omit it or set it to undefined for uncontrolled mode; in this case you can supply a defaultValue as the initial value.

Hide source code

Disabled Options

Inside options, set disabled: true on any choice to disable it.

Hide source code

Grouping

options also accepts option groups.

Hide source code

Remote Loading

Set the loading and showPopoverEmpty props and listen to the input event to reflect remote-loading UI states.

Hide source code

Append Mode

After selecting an option, append it to the existing input instead of replacing the content by enabling the append prop.
Use the filter and shouldShowPopover functions to control which options appear and when the popover is shown.

Hide source code

Virtual List

Enabling the virtualScroll property activates the virtual list, which can be turned on to improve performance when there is a large amount of option data.

Hide source code

Custom Rendering

option slot customizes option rendering, group-label slot customizes group label rendering.

Hide source code

More Options

This AutoComplete has most of Input component's features.

Disabled, Readonly, Loading & Clearable

Shape

Size

Slot

prefix
suffix

Composite

Status

Expose

Hide source code

API

AutoCompleteProps

AttributeTypeOptionalDefaultDescriptionVersion
modelValuestring | nullTrueValue of the auto complete input (controlled mode), supports v-model.0.0.2
defaultValuestring | nullTrueDefault value of the auto complete input (uncontrolled mode).0.0.2
optionsstringTrueList of options.0.0.2
placeholderstringTruePlaceholder text.0.0.2
disabledbooleanTruefalseWhether the input is disabled.0.0.2
readonlybooleanTruefalseWhether the input is read-only.0.0.2
clearablebooleanTruefalseWhether to show a clear button.0.0.2
loadingbooleanTruefalseWhether to show a loading state.0.0.2
size'medium' | 'large' | 'small'True'medium'Size of the auto complete input.0.0.2
shape'rect' | 'round'True'rect'Shape of the auto complete input.0.0.3
showPopoverEmptybooleanTruefalseWhether to display the popover when the options list is empty.0.0.2
shouldShowPopover(value: string, optionsFiltered: (string | AutoCompleteOption | AutoCompleteGroupOption)[]) => booleanTrueFunction to determine whether to show the popover while inputting.0.0.2
filter(keyword: string, options: (string | AutoCompleteOption | AutoCompleteGroupOption)[]) => (string | AutoCompleteOption | AutoCompleteGroupOption)[]TrueFunction to filter the options.0.0.2
appendbooleanTruefalseAppend mode.0.0.2
virtualScrollbooleanTruefalseWhether render options with virtual list.0.0.3
virtualListPropsOmit<VirtualListProps, 'list' | 'fixedHeight'> & RestAttrsTrueProperties of virtual list.0.0.3
borderRadiusNumberOrPercentage | NumberOrPercentage[]True0.0.2
status'success' | 'warning' | 'error' | 'normal'True'normal'Form validation status.0.0.2
autofocusbooleanTruefalseNative <input> autofocus attribute.0.0.2
popoverPropsOmit<PopoverProps, 'visible' | 'content'> & EmitEvent<PopoverEvents>True0.2.0
optionsDestroyOnHidebooleanTruefalseWhether the dropdown options will be destroyed when hidden.0.0.3
pollSizeChangebooleanTruefalseEnables polling for component size changes. This may impact performance.0.1.0

AutoCompleteEvents

EventParameterDescriptionVersion
inputvalue: string, e: EventCallback fired when the input value changes.0.0.2
update:modelValuevalue: stringCallback fired when modelValue is updated.0.0.2
changevalue: string, e: Event | undefinedCallback fired when the input content changes.0.0.2
clearvalue: stringCallback fired when the clear button is clicked.0.0.2
blure: FocusEventCallback fired when the input loses focus.0.0.2
focuse: FocusEventCallback fired when the input receives focus.0.0.2
selectvalue: string, option: string | AutoCompleteOption, e: MouseEventCallback fired when an option is selected.0.0.2
dropdownOpenCallback when the dropdown panel is opened.0.2.0
dropdownCloseCallback when the dropdown panel is closed.0.2.0

AutoCompleteSlots

SlotParameterDescriptionVersion
prefixPrefix content.0.0.2
suffixSuffix content.0.0.2
optionoption: string | AutoCompleteOptionCustom option content.0.0.2
group-labeloption: AutoCompleteGroupOptionLabel for option groups.0.0.2

AutoCompleteExpose

AttributeTypeOptionalDefaultDescriptionVersion
focus() => voidFalseFocus the control.0.0.2
blur() => voidFalseBlur the control.0.0.2
clear() => voidFalseClear the current input.0.0.2
select() => voidFalseSelect all text in the input.0.0.2

Option, GroupOption

ts
export interface Option<T = any> {
	value: T
	label: string
}

export interface GroupOption<T = any> {
	children: (Option<T> | string)[]
	type: 'group'
}

OptionListOption, OptionListOption

ts
export interface OptionListOption<T = any> extends Option<T> {
	disabled?: boolean
	key?: string | number | symbol
}

export interface OptionListGroupOption extends GroupOption {
	label: string
	key: string | number | symbol
	children: (OptionListOption | string)[]
}

AutoCompleteOption, AutoCompleteGroupOption

ts
export interface AutoCompleteOption extends OptionListOption<string> {
}

export interface AutoCompleteGroupOption extends OptionListGroupOption {
	children: (AutoCompleteOption | string)[]
}

RestAttrs

ts
import type { StyleValue } from 'vue'

export type VueClassValue = string | Record<string, any> | VueClassValue[]
export type VueStyleValue = StyleValue

export type RestAttrs = {
	style?: VueStyleValue | null
	class?: VueClassValue | null
	[x: string]: any
}