Skip to content

useAutocomplete

ts
function useAutocomplete<TItem>(options: UseAutocompleteOptions<TItem>): AutocompleteState<TItem>;

useAutocomplete performs two independent list requests: one for current selected identities and one for the active search query. It merges the results in that order and removes duplicate identities, so currently selected values remain renderable after search criteria change.

Returned state and actions

ValueDescription
itemsSelected items first, followed by query items not already present.
currentValueItems, queryItemsRaw results of the two requests.
loading, errorCombined loading flag and latest error.
loadCurrentItems()Loads only selected identities.
loadItems()Loads only search results.
initialize() / refresh()Loads both request groups concurrently.

When itemDisabled is provided, each returned item receives a derived disabled boolean; no server object is mutated.

Released under the MIT License.