AstrolUI AstrolUI
Yellow Orange Red Green Blue Purple Custom color
Light mode
ComboBox

1. Demo AstrolComboBox

@using Astrol.Component.Basic.Form
<AstrolLabel TItem="Person" For="@nameof(Person.Name)" />
<AstrolComboBox HasContentInput="true"
                ShowOpenIcon="true"
                TItem="Person"
                Placeholder="Search for a person"
                Id="@nameof(Person.Name)"
                Display="p => p.Name"
                @bind-Value="person"
                NoSearchResultText="No results found"
                DataList="list" />
<div><b>Id: </b>@person?.Id</div>
<div><b>Name: </b>@person?.Name</div>
<div><b>Age: </b>@person?.Age</div>
<div><b>Sex: </b>@person?.Sex</div>
@code {
   private Person? person;
   List<Person> list = new List<Person> {
       new Person { Id = 1, Name = "Juan", Age = 25, Sex = true },
       new Person { Id = 2, Name = "Ana", Age = 30, Sex = false },
       new Person { Id = 3, Name = "Pedro", Age = 42, Sex = true },
       new Person { Id = 4, Name = "María", Age = 19, Sex = false },
       new Person { Id = 5, Name = "Carlos", Age = 55, Sex = true }
   };
   public class Person {
       public int Id { get; set; }
       public string Name { get; set; } = string.Empty;
       public int Age { get; set; }
       public bool Sex { get; set; }
   }
}

Supported parameters

  • TItem (object), option type (required).
  • DataList (IEnumerable<TItem>), options to display.
  • Display (Func<TItem, string?>), text of each option, e.g. Display="p => p.Name" (recommended).
  • PropertyShow (string), alternative to Display using the property name (supports "A.B" paths).
  • Value (TItem) / ValueChanged, selected item; supports @bind-Value.
  • InitialValue (TItem), initial value without two-way binding.
  • OnChange (EventCallback<ChangeEventArgs>), raised when the selection changes; Value holds the item or null.
  • Filtrable (bool), filters while typing, ignoring case and accents (default true).
  • Placeholder (string), input placeholder.
  • HasContentInput (bool), uses the AstrolContentInput container (default false).
  • ShowOpenIcon (bool), shows the open icon on the right, only if HasContentInput is true (default false).
  • PropertyShowIsHtml (bool), option text is HTML. Trusted content only: it is inserted unescaped.
  • NoSearchResultText (string), text when there are no results (default follows the app language).
  • Id (string) and Class (string), HTML id and css class.
  • The selection is compared with Equals: Value / InitialValue must be an instance from DataList (or TItem must override Equals, e.g. a record).
  • When Filtrable is false the input is read-only. Typing text that exactly matches an option selects it; on leaving the field, if the text does not match the selection, both the text and the selection are cleared.
  • Methods (via @ref): ChangeValue(item) selects an item from code and ChangeDataList(list, selected) replaces the options (and optionally the selection).
  • Keyboard: arrows to move, Enter to select and Esc to close. The dropdown opens upwards when there is no room below and works inside grids and modals.
Markdown for AI © 2026 AstrolUI v10.0.13