Skip to content

Autocomplete

uitemplate

Highlight color for the selected suggestion

Installation

$ bunx termuijs add autocomplete

Copies the source into src/components/autocomplete/ and installs @termuijs/core, @termuijs/widgets.

Usage

ts
import { Autocomplete } from '@termuijs/ui'
ts
new Autocomplete(style: Partial<Style> = {}, options: AutocompleteOptions = { items: [] })

API Reference

Autocomplete

PropTypeRequiredDescription
itemsstring[]requiredList of search suggestions / candidates
onSelect(value: string) => voidoptionalCallback when an item is selected or submitted
onChange(value: string) => voidoptionalCallback when the query text changes
filter(query: string, item: string) => booleanoptionalCustom filter function to override default lowercase startsWith matching
maxSuggestionsnumberoptionalMaximum number of suggestions to display in dropdown
placeholderstringoptionalPlaceholder text when query is empty
highlightColorColoroptionalHighlight color for the selected suggestion
#template#autocomplete