# SbAutocomplete A text input with dropdown suggestions, supporting both static item lists and async search functions. ## Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | Value | TItem? | null | The selected item (two-way bindable) | | ValueChanged | EventCallback\ | - | Callback when selection changes | | Items | IEnumerable\? | null | Static items to search from | | SearchFunc | Func\\>\>? | null | Async function to fetch items | | TextField | Func\ | item => item.ToString() | Function to get display text | | ValueField | Func\ | item => item | Function to get value for comparison | | MinLength | int | 1 | Minimum characters before searching | | DebounceMs | int | 300 | Debounce delay in milliseconds | | MaxResults | int | 10 | Maximum results to show | | Placeholder | string? | null | Placeholder text (when null, uses localized default) | | Clearable | bool | true | Whether to show clear button when a value is selected | | Disabled | bool | false | Whether the input is disabled | | Id | string? | null | Element ID for form association | | Label | string? | null | Label text displayed above the input | | Required | bool | false | Whether the field is required | | Class | string? | null | Additional CSS classes | | Style | string? | null | Inline styles | ## Events | Event | Type | Description | |-------|------|-------------| | ValueChanged | EventCallback\ | Fired when the selected item changes | ## Templates / Slots (RenderFragments) | Slot | Type | Description | |------|------|-------------| | ItemTemplate | RenderFragment\ | Custom template for dropdown items | | NoResultsTemplate | RenderFragment | Template shown when no results found | ### Template Usage Examples #### Custom ItemTemplate ```razor
@user.Name
@user.Email
``` #### NoResultsTemplate ```razor No products found Add new product ``` ## CSS Classes - `sb-autocomplete` - Base class - `sb-autocomplete__label` - Label element - `sb-autocomplete__required` - Required asterisk - `sb-autocomplete__input-wrapper` - Input container - `sb-autocomplete__input` - Text input - `sb-autocomplete__spinner` - Loading spinner - `sb-autocomplete__clear` - Clear button - `sb-autocomplete__icon` - Chevron icon - `sb-autocomplete__dropdown` - Dropdown panel - `sb-autocomplete__dropdown--flip-up` - Dropdown flips upward - `sb-autocomplete__option` - Individual option - `sb-autocomplete__option--highlighted` - Keyboard-highlighted option - `sb-autocomplete__option--selected` - Selected option - `sb-autocomplete__no-results` - No results container ## Accessibility - Clear button has aria-label - Keyboard: Arrow keys to navigate, Enter to select, Escape to close ## Examples ### Basic with Static Items ```razor ``` ### Async Search ```razor @code { private async Task> SearchUsersAsync(string query) { return await UserService.SearchAsync(query); } } ``` ### With Minimum Length ```razor ``` ### Required Field ```razor ``` ### Disabled State ```razor ```