Generic Autocomplete

I thought I’d take a stab at creating a generic autocomplete Blazor component. While researching I came across the HTML Datalist tag to add a list of options to an input element. The combination provided a lot of the functionality I was looking for. Specifically the dropdown filtered by the text in the input. I added some additional code to make the component generic and some validation to ensure what the user enters is on the list. If it isn’t, the user gets a validation error message. I also included the ability to automatically select an option on the list if there is only one remaining after filtering and pressing enter or tab.

I’m pretty happy with the result. You can try it out at the Blazor Component Authority Demonstration Application and also take a look at the source code. I hope you find it useful. Thanks for reading.

Site Footer

Sliding Sidebar