Button Group
Joins related buttons into one control, horizontally or vertically.
ButtonGroup is new in v0.4. It wraps a set of Buttons, removes the gaps between them and squares the inner corners, so they read as one control. The buttons keep their own variants, sizes and click handlers.
Installation
bash
shellui add button-group
Usage
Basic
<ButtonGroup>
<Button Variant="ButtonVariant.Outline">Day</Button>
<Button Variant="ButtonVariant.Outline">Week</Button>
<Button Variant="ButtonVariant.Outline">Month</Button>
</ButtonGroup>Vertical
Set Orientation="vertical" to stack the buttons.
<ButtonGroup Orientation="vertical">
<Button Variant="ButtonVariant.Outline">Top</Button>
<Button Variant="ButtonVariant.Outline">Middle</Button>
<Button Variant="ButtonVariant.Outline">Bottom</Button>
</ButtonGroup>Showing a selection
ButtonGroup only handles layout. To highlight the active button, switch its Variant yourself. For a control that tracks its own value, use Toggle Group.
Showing: 30 days
<ButtonGroup>
@foreach (var range in ranges)
{
<Button Variant="@(range == selected ? ButtonVariant.Default : ButtonVariant.Outline)"
OnClick="() => selected = range">
@range
</Button>
}
</ButtonGroup>
<p class="mt-3 text-sm text-muted-foreground">Showing: @selected</p>
@code {
private readonly string[] ranges = ["7 days", "30 days", "90 days"];
private string selected = "30 days";
}API Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
Orientation |
string |
"horizontal" |
horizontal or vertical |
ChildContent |
RenderFragment? |
null |
The buttons |
Class |
string? |
null |
Additional CSS classes |
Accessibility
- Renders a
role="group"container; addaria-labelto name the group - Each button keeps its own focus ring and keyboard behavior