Autocomplete
An input field with auto-completion functionality that shows suggestions as the user types.
Basic Usage
Basic Autocomplete
Simple autocomplete with a list of suggestions
Custom Configuration
Custom Configuration
Autocomplete with custom minLength and maxSuggestions
Disabled State
Disabled State
Autocomplete in disabled state
Usage
Basic Usage
import { Autocomplete } from 'fluxo-ui';
const items = ['Apple', 'Banana', 'Cherry', 'Date'].map(v => ({ label: v, value: v }));
function MyComponent() {
const [value, setValue] = useState('');
const [selectedValue, setSelectedValue] = useState(null);
return (
<Autocomplete
items={items}
value={value}
selectedValue={selectedValue}
placeholder="Type to search..."
onChange={(e) => setValue(e.value)}
onSelect={(e) => setSelectedValue(e.value)}
/>
);
}Advanced Usage
import { Autocomplete } from 'fluxo-ui';
function MyComponent() {
const [value, setValue] = useState('');
const [selectedValue, setSelectedValue] = useState(null);
const [items, setItems] = useState([]);
const [loading, setLoading] = useState(false);
const allItems = ['Apple', 'Banana', 'Cherry', 'Date', 'Elderberry'].map(v => ({ label: v, value: v }));
const handleFilter = async (query) => {
setLoading(true);
setTimeout(() => {
const filtered = allItems.filter(item =>
item.label.toLowerCase().includes(query.toLowerCase())
);
setItems(filtered);
setLoading(false);
}, 500);
};
return (
<Autocomplete
items={items}
value={value}
selectedValue={selectedValue}
placeholder="Search fruits..."
minLength={2}
maxSuggestions={3}
debounceMs={300}
loading={loading}
onChange={(e) => setValue(e.value)}
onSelect={(e) => {
setSelectedValue(e.value);
console.log('Selected:', e.value);
}}
onFilter={handleFilter}
/>
);
}Import
import { Autocomplete } from 'fluxo-ui';Props
itemsreqListItem[]Array of suggestion items with { label: string, value: any } structure
itemsreqListItem[]Array of suggestion items with { label: string, value: any } structure
valuestring"''"Current input value (controlled)
valuestring"''"Current input value (controlled)
selectedValueanyCurrently selected item value
selectedValueanyCurrently selected item value
onChange(event: ComponentEvent<string>) => voidCallback fired when input value changes. Receives event object with value, name, and args
onChange(event: ComponentEvent<string>) => voidCallback fired when input value changes. Receives event object with value, name, and args
onSelect(event: ComponentEvent<any>) => voidCallback fired when a suggestion is selected. Receives the selected item value
onSelect(event: ComponentEvent<any>) => voidCallback fired when a suggestion is selected. Receives the selected item value
onFilter(query: string) => void | Promise<void>Callback for filtering items or loading async data based on input
onFilter(query: string) => void | Promise<void>Callback for filtering items or loading async data based on input
placeholderstring"'Type to search...'"Placeholder text for the input
placeholderstring"'Type to search...'"Placeholder text for the input
requiredboolean"false"Mark the input as required
requiredboolean"false"Mark the input as required
readonlyboolean"false"Make the input read-only
readonlyboolean"false"Make the input read-only
disabledboolean"false"Disable the input
disabledboolean"false"Disable the input
minLengthnumber"1"Minimum characters before showing suggestions
minLengthnumber"1"Minimum characters before showing suggestions
maxSuggestionsnumberMaximum number of suggestions to display (filters the items list)
maxSuggestionsnumberMaximum number of suggestions to display (filters the items list)
debounceMsnumber"300"Debounce delay in milliseconds before calling onFilter
debounceMsnumber"300"Debounce delay in milliseconds before calling onFilter
loadingboolean"false"Show loading indicator in the input
loadingboolean"false"Show loading indicator in the input
emptyMessagestring"'No results found'"Message shown when no suggestions match
emptyMessagestring"'No results found'"Message shown when no suggestions match
renderItem(item: ListItem, index: number, isSelected: boolean, isHighlighted: boolean) => ReactNodeCustom renderer for suggestion items
renderItem(item: ListItem, index: number, isSelected: boolean, isHighlighted: boolean) => ReactNodeCustom renderer for suggestion items
autoFocusboolean"false"Auto focus the input on mount
autoFocusboolean"false"Auto focus the input on mount
idstringHTML id attribute for the input
idstringHTML id attribute for the input
namestringName attribute for the input (used in forms)
namestringName attribute for the input (used in forms)
argsanyAdditional arguments passed to onChange/onSelect handlers
argsanyAdditional arguments passed to onChange/onSelect handlers
classNamestringAdditional CSS classes for the input
classNamestringAdditional CSS classes for the input
Features
Type-ahead Search
Shows matching suggestions as the user types with configurable minimum character threshold
Async Filtering
onFilter callback with built-in debounce supports server-side search and dynamic data loading
Suggestion Limit
Control the number of visible suggestions with maxSuggestions to keep the dropdown focused
Loading State
Built-in loading indicator shown while async suggestions are being fetched
Custom Item Renderer
renderItem prop allows fully custom suggestion item layouts including icons and metadata
Separate Select Callback
Distinct onChange (typed text) and onSelect (chosen item) callbacks for full control over state
Accessibility
ARIA combobox pattern with keyboard navigation, focus management, and screen reader support
Theming
Full dark/light and 5 brand themes supported via CSS variables with zero extra configuration