Toggle Group
A row of toggles where one, or several, can be pressed.
Installation
bash
shellui-native add toggle-group
Platforms: MAUI · Avalonia. Also installs icon, element-extensions.
Usage
Single
<ui:ToggleGroup Value="center">
<ui:ToggleGroupItem Value="left" Text="Left" />
<ui:ToggleGroupItem Value="center" Text="Center" />
<ui:ToggleGroupItem Value="right" Text="Right" />
</ui:ToggleGroup><ui:ToggleGroup Value="center">
<ui:ToggleGroupItem Value="left" Text="Left" />
<ui:ToggleGroupItem Value="center" Text="Center" />
<ui:ToggleGroupItem Value="right" Text="Right" />
</ui:ToggleGroup>Not available on yet
Multiple
<ui:ToggleGroup Multiple="True" Values="{Binding Formats}">
<ui:ToggleGroupItem Value="bold" Text="B" />
<ui:ToggleGroupItem Value="italic" Text="I" />
<ui:ToggleGroupItem Value="underline" Text="U" />
</ui:ToggleGroup><ui:ToggleGroup Multiple="True" Values="{Binding Formats}">
<ui:ToggleGroupItem Value="bold" Text="B" />
<ui:ToggleGroupItem Value="italic" Text="I" />
<ui:ToggleGroupItem Value="underline" Text="U" />
</ui:ToggleGroup>Not available on yet
MAUI and Avalonia
On Avalonia the items are also tab stops, pressed with Enter or Space.
API
ToggleGroup
XAML children go to Items.
| Property | Type | Default | Description |
|---|---|---|---|
Multiple |
bool |
false |
Allows several items to be pressed at once. |
Value |
string |
— | Pressed item with Multiple="False". Two-way bindable. |
Values |
IList<string> (MAUI) · IList<string>? (Avalonia) |
null |
The pressed items' Values in Multiple mode. |
Variant |
ToggleGroupVariant |
Default |
Visual style. One of Default, Outline. |
| Event | Arguments | Description |
|---|---|---|
ValueChanged |
string? |
User input only: setting Value or Values from code or a binding doesn't raise them. |
ValuesChanged |
IReadOnlyList<string> |
The selection changed. |
| Method | Description |
|---|---|
IsPressed(string value) |
Whether it's pressed. Two-way bindable. |
ToggleGroupItem
| Property | Type | Default | Description |
|---|---|---|---|
Value |
string |
— | Value this item stands for. |
Text |
string |
— | Text shown by the component. |
Icon |
IconName |
None |
Lucide icon from IconName; None for no icon. |