Skip to content
daisyBlazor

Autocomplete

A type-ahead input whose suggestions come from an async SearchFunc, so it works the same against an in-memory list or a remote API. Typing is debounced and stale searches are cancelled.
Data input.dropdownReplaces MudAutocomplete
Cover · <Autocomplete>

Examples

Search a list

SearchFunc gets the text and a cancellation token; suggestions appear after MinCharacters (2 by default).

Selected: (none)

website/Examples/DataInput/AutocompleteBasicExample.razor Source

Bind a record, show it as text with ToStringFunc and style each suggestion with ItemTemplate.

Nothing picked yet.

website/Examples/DataInput/AutocompleteObjectsExample.razor Source

API

<Autocomplete<T>>

DaisyBlazor

Parameters

  • Adornment Adornment
    = Adornment.None

    Where AdornmentIcon is placed (start or end); defaults to none, which hides it.

  • AdornmentIcon string
    = null

    Icon rendered inside the input at the side given by Adornment.

  • ClearAriaLabel string
    = null

    Accessible label for the clear button. Null uses the app-wide Strings.

  • Clearable bool
    = false

    Shows a clear button inside the input that empties the text and resets the value.

  • CoerceText bool
    = false

    Accepted for MudBlazor compatibility; currently has no effect.

  • CoerceValue bool
    = false

    Accepted for MudBlazor compatibility; currently has no effect.

  • DebounceInterval int
    = 300

    Delay in milliseconds after the last keystroke before searching; defaults to 300.

  • Dense bool
    = false

    Renders a smaller input using the daisyUI input-sm class.

  • Disabled bool
    = false

    Disables the input and applies the daisyUI input-disabled class.

  • Label string
    = null

    Text rendered in a daisyUI label above the input.

  • Margin Margin
    = Margin.None

    Accepted for MudBlazor compatibility; currently has no effect.

  • MaxItems int
    = 20

    Maximum number of results shown in the dropdown; defaults to 20.

  • MinCharacters int
    = 2

    Minimum number of typed characters before the search runs; defaults to 2.

  • NoItemsText string
    = null

    Text shown in the dropdown when a search returns no results. Null uses the app-wide Strings.

  • Placeholder string
    = null

    Placeholder text shown in the input when it is empty.

  • Required bool
    = false

    Shows RequiredError once the user has typed and no value is selected.

  • RequiredError string
    = null

    Error message shown below the input when Required is set and no value is selected.

  • ResetValueOnEmptyText bool
    = false

    Clears the selected value when the user deletes all text from the input.

  • SearchFunc Func<string, CancellationToken, Task<IEnumerable<T>>>
    = null

    Async search invoked with the typed text and a cancellation token; returns the dropdown results.

  • ToStringFunc Func<T, string>
    = null

    Converts an item to its display text; falls back to ToString() when not set.

  • Value T
    = null

    The currently selected item; supports two-way binding with @bind-Value.

  • Variant Variant
    = Variant.Outlined

    Accepted for MudBlazor compatibility; currently has no effect (the input is always input-bordered).

  • Class string
    = null

    Extra CSS classes added to the root form-control element.

  • Style string
    = null

    Inline CSS styles applied to the root form-control element.

Events

  • ValueChanged EventCallback<T>

    Raised when an item is selected, cleared, or reset by emptying the text.

Content

  • ItemTemplate RenderFragment<T>

    Custom content for each result in the dropdown; defaults to the item's display text.

  • NoItemsTemplate RenderFragment

    Custom content shown when a search returns no results; overrides NoItemsText.

From MudAutocomplete

Autocomplete keeps MudAutocomplete's parameter names, so most markup moves over by dropping the Mud prefix. See the migration guide for the shared enums, icons and services.

<MudAutocomplete> <Autocomplete>
Something went wrong while running the docs. Reload