Skip to main content

AsyncAutoComplete

An MUI Autocomplete that fetches options from an async source as the user types, with built-in debounce and loading state.

πŸ“– Storybook

Preview​

Import​

// Original
import { AsyncAutoComplete } from "@xocialive/ui-components";

// V2 β€” recommended for new code (typed, more flexible)
import { AsyncAutoCompleteV2 } from "@xocialive/ui-components";
import type { AsyncAutoCompleteV2Props } from "@xocialive/ui-components";

V2 basic usage​

<AsyncAutoCompleteV2
label="Assign user"
fetchOptions={async (search) => {
const res = await api.get(`/users?q=${search}`);
return res.data.map((u) => ({ label: u.name, value: u.id }));
}}
value={selectedUser}
onChange={(opt) => setSelectedUser(opt)}
/>

V2 Props​

PropTypeDefaultDescription
labelstringβ€”Input label
fetchOptions(search: string) => Promise<Option[]>β€”Async option loader
valueOption | nullβ€”Controlled value
onChange(option: Option | null) => voidβ€”Change handler
debounceMsnumber300Debounce delay for fetch calls
minCharsnumber0Minimum characters before fetching
disabledbooleanfalseDisables the input
placeholderstringβ€”Input placeholder
sxSxProps<Theme>β€”Root element style overrides

Option type​

type Option = {
label: string;
value: string | number;
};