🆕 feat(Combobox): supports select custom chip when using SelectionContent (#2445)

* 🆕 feat(Combobox): supports select custom chip when using SelectionContent

* update
This commit is contained in:
capdiem
2025-06-07 09:56:07 +08:00
committed by GitHub
parent 10cef731e9
commit 767e0c9918
4 changed files with 68 additions and 23 deletions

View File

@@ -1 +1,35 @@
TODO
<MRow>
<MCol Cols="12">
<MCombobox @bind-Value="_chips"
Items="_items"
ItemText="u => u"
ItemValue="u => u"
Chips
Clearable
Label="Your favorite hobbies"
Multiple
PrependIcon="mdi-filter-variant"
Solo>
<SelectionContent>
<MChip Close
IsActive="@context.Selected"
OnClick="@context.Select"
OnCloseClick="() => Remove(context.Text)">
<strong>@context.Text</strong>&nbsp;
<span>(interest)</span>
</MChip>
</SelectionContent>
</MCombobox>
</MCol>
</MRow>
@code {
private List<string> _chips = ["Programming", "Playing video games", "Watching movies", "Sleeping"];
private List<string> _items = ["Streaming", "Eating"];
private void Remove(string item)
{
_chips.Remove(item);
}
}

View File

@@ -19,6 +19,7 @@
Chips>
<SelectionContent>
<MChip IsActive="@context.Selected"
OnClick="@context.Select"
Disabled="@context.Disabled">
<MAvatar Class="primary"
Left>