ShellUI Logo
ShellUI

Multi Select

Searchable multi-select for objects, shown as chips

MultiSelect<TItem, TKey> picks several objects from a list, with a search box. Selected items appear as removable chips.

Installation

shellui add multi-select

Usage

<MultiSelect TItem="Person" TKey="int"
    Items="_people"
    @bind-Values="_selected"
    KeySelector="p => p.Id"
    DisplaySelector="p => p.Name"
    Placeholder="Add people" />

<p>@_selected.Count selected</p>

@code {
    private List<Person> _selected = new();
}
@code {
    private List<Person> _people = new()
    {
        new(1, "Ada Lovelace", "Engineering"),
        new(2, "Grace Hopper", "Engineering"),
        new(3, "Katherine Johnson", "Research"),
    };

    record Person(int Id, string Name, string Team);
}

Custom chips

<MultiSelect TItem="Person" TKey="int" Items="_people" @bind-Values="_selected"
    KeySelector="p => p.Id" DisplaySelector="p => p.Name">
    <ChipTemplate>@context.Name (@context.Team)</ChipTemplate>
</MultiSelect>

API Reference

PropertyTypeDefaultDescription
TItemGeneric type—The item type
TKeyGeneric type—The key type returned by KeySelector
ItemsIEnumerable<TItem>requiredItems to choose from
ValuesList<TItem>empty listSelected items (supports @bind-Values)
ValuesChangedEventCallback<List<TItem>>—Raised when the selection changes
KeySelectorFunc<TItem, TKey>requiredUnique key for each item
DisplaySelectorFunc<TItem, string>?nullText shown for an item (defaults to ToString())
SearchPredicateFunc<TItem, string, bool>?nullCustom search match (defaults to a case-insensitive match on the display text)
ChipTemplateRenderFragment<TItem>?nullCustom rendering of each selected chip
OptionTemplateRenderFragment<TItem>?nullCustom rendering for each option in the list
Placeholderstring"Select..."Text shown when nothing is selected
SearchPlaceholderstring"Search..."Placeholder of the search box
EmptyTextstring"No results found."Text shown when the search matches nothing
DisabledboolfalseDisables the control
CloseOnScrollboolfalseClose the list when the page scrolls
Classstring?nullAdditional CSS classes

On this page