Skip to content

KAutoComplete

Get some recommended tips based on the current input.

Install

bash
pnpm add @ikun-ui/auto-complete
bash
yarn add @ikun-ui/auto-complete
bash
npm install @ikun-ui/auto-complete

Basic usage

Clearable

Make the AutoComplete clearable with the clearable attribute.

Custom Render

Through slots you can customize option rendering

AutoComplete Props

NameTypeDefaultDescription
sizesm | md |lgmdsize of AutoComplete.
valuestring-Binding value
disabledbooleanfalseDisable the AutoComplete
clearablebooleanfalsewhether to show clear button
placeholderstringfalseAutoComplete's placeholder
appendstring-The class name of the append button icon, following the unocss standard
prependstring-The class name of the prepend button icon, following the unocss standard
triggerOnFocusbooleanfalseTriggered when mouse is focused.
fetchSuggestionsFetchSuggestionType-Enter suggestion callback method.
useCompositionInputbooleanfalseBind value will be updated after the composition input ends
clsInputstring''Additional class for input component
clsstring''Additional class for component
attrsany{}Additional attributes
typescript
export type FetchSuggestionType = (
	params: string | number,
	cb: (res: AutoCompleteItems[]) => void
) => void;
export type AutoCompleteItems = {
	[string]: any;
	value: string | number;
};

AutoComplete Events

NameDescriptionType
updateValueTriggered after selecting input suggestion(value: string)=> void
enterEvent fired when enter is pressed(e: Event)=> void
keydownEvent fired when keyboard is pressed(e: Event)=> void
changeEvent fired when the value is changes(e: Event)=> void
compositionstartThe compositionstart event is fired when a text composition system(e: CompositionEvent)=> void
compositionendThe compositionend event is fired when a text composition system(e: CompositionEvent)=> void
compositionInputEvent fired when enable useCompositionInput(e: CompositionEvent)=> void
triggerPrependEvent fired on prepend button(value: HTMLInputElement.value)=> void
triggerAppendEvent fired on append button(value: HTMLInputElement.value)=> void
searchWhen search is true and you press enter or click the prepend button or click the append button, the event will be triggered.(value: HTMLInputElement.value)=> void

AutoComplete Slots

NameDescription
defaultCustomize option content.
prefixCustomize AutoComplete prefix content
suffixCustomize AutoComplete suffix content

MIT Licensed