Select Dropdown select input for picking from a list of options, styled to match the ShellUI design system.
Select renders a styled native <select> element. SelectTrigger, SelectContent, and SelectItem sub-components are planned for a future release and are not yet implemented in v0.3.0-alpha.2.
< Select @bind-Value = "_framework" >
< SelectTrigger Placeholder = "Pick a framework..." />
< SelectContent >
< SelectItem Value = "blazor" >Blazor</ SelectItem >
< SelectItem Value = "next" >Next.js</ SelectItem >
< SelectItem Value = "nuxt" >Nuxt</ SelectItem >
< SelectItem Value = "sveltekit" >SvelteKit</ SelectItem >
</ SelectContent >
</ Select >
@code {
private string _framework = "" ;
}
< EditForm Model = "_form" >
< div class = "space-y-4 w-60" >
< Label For = "role" >Role</ Label >
< Select @bind-Value = "_form.Role" >
< SelectTrigger Placeholder = "Select a role..." />
< SelectContent >
< SelectItem Value = "admin" >Admin</ SelectItem >
< SelectItem Value = "editor" >Editor</ SelectItem >
< SelectItem Value = "viewer" >Viewer</ SelectItem >
</ SelectContent >
</ Select >
</ div >
</ EditForm >
@code {
private MyFormModel _form = new ();
public class MyFormModel { public string Role { get ; set ; } = "" ; }
}
< Select @bind-Value = "_language" >
< SelectTrigger Placeholder = "Choose a language..." />
< SelectContent >
< p class = "px-2 py-1 text-xs font-semibold text-muted-foreground" >.NET</ p >
< SelectItem Value = "csharp" >C#</ SelectItem >
< SelectItem Value = "fsharp" >F#</ SelectItem >
< p class = "mt-1 px-2 py-1 text-xs font-semibold text-muted-foreground" >JavaScript</ p >
< SelectItem Value = "ts" >TypeScript</ SelectItem >
< SelectItem Value = "js" >JavaScript</ SelectItem >
</ SelectContent >
</ Select >
@code {
private string _language = "" ;
}
< Select @bind-Value = "_theme" >
< SelectTrigger />
< SelectContent >
< SelectItem Value = "system" >System</ SelectItem >
< SelectItem Value = "light" >Light</ SelectItem >
< SelectItem Value = "dark" >Dark</ SelectItem >
</ SelectContent >
</ Select >
@code {
private string _theme = "system" ;
}
< Select @bind-Value = "_plan" @bind-Value:after = "OnPlanChanged" >
< SelectTrigger Placeholder = "Select plan..." />
< SelectContent >
< SelectItem Value = "free" >Free</ SelectItem >
< SelectItem Value = "pro" >Pro</ SelectItem >
< SelectItem Value = "enterprise" >Enterprise</ SelectItem >
</ SelectContent >
</ Select >
< p class = "text-sm text-muted-foreground" >Selected: @ _plan</ p >
@code {
private string _plan = "" ;
private void OnPlanChanged () => Console. WriteLine ( $"Plan changed to { _plan } " );
}
In v0.2.x Select was a single component with Items and @bind-SelectedValue. Replace it with the new compositional pattern:
@* v0.2.x — OLD *@
< Select Items = "_options" @bind-SelectedValue = "_selected" Placeholder = "Pick one..." / >
@* v0.3.0-alpha1 — NEW *@
< Select @bind-Value = "_selected" >
< SelectTrigger Placeholder = "Pick one..." />
< SelectContent >
@foreach ( var opt in _options)
{
< SelectItem Value = " @ opt . Value " > @ opt.Label</ SelectItem >
}
</ SelectContent >
</ Select >
Parameter Type Default Description Valuestring?nullThe currently selected value ValueChangedEventCallback<string?>— Fires when the user selects an item Classstring?nullAdditional CSS classes on the root element
Parameter Type Default Description Placeholderstring?nullShown when no value is selected Classstring?nullAdditional CSS classes
Parameter Type Default Description ChildContentRenderFragment— <SelectItem> elementsClassstring?nullAdditional CSS classes on the dropdown panel
Parameter Type Default Description Valuestring— The raw value submitted when this item is selected ChildContentRenderFragment— Display label Classstring?nullAdditional CSS classes