ButtonGroup
elements man ui/templates/button-groupRelated buttons, or an input and its buttons, joined into one control.
Exampleimport { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from "@elements/ui/button-group"; import { Button } from "@elements/ui/button"; <ButtonGroup label="Message actions"> <Button>Archive</Button> <Button>Report</Button> <Button>Snooze</Button> </ButtonGroup>
Parts
| Part | What it is |
|---|---|
ButtonGroupSeparator |
A rule between two members. |
ButtonGroupText |
A text or label segment. |
.button-group |
The base button-group classes, extended. Usable without the template. |
Attributes
ButtonGroup
| Attribute | Type | Default | Description |
|---|---|---|---|
orientation |
"horizontal" | "vertical" |
"horizontal" |
A row or a column. |
label |
string |
"" |
The group's accessible name (aria-label). |
class |
string |
"" |
Extra classes. |
attrs |
Record<string, string | number | boolean | undefined> |
{} |
aria-labelledby, id, data-*. |
ButtonGroupSeparator
| Attribute | Type | Default | Description |
|---|---|---|---|
orientation |
"horizontal" | "vertical" |
"vertical" |
The rule's direction: vertical between buttons in a row. |
ButtonGroupText
| Attribute | Type | Default | Description |
|---|---|---|---|
htmlFor |
string |
"" |
Renders a <label> for that id instead of a <div>. |
Slots
| Slot | Part | Content |
|---|---|---|
default |
ButtonGroup |
Buttons, Inputs, NativeSelects, InputGroups, ButtonGroupText, separators, or nested ButtonGroups. |
Keyboard
| Keys | Action |
|---|---|
Tab |
Moves through the members one by one (each is its own tab stop). |
Data attributes
| Attribute | Values | On |
|---|---|---|
data-orientation |
"horizontal" | "vertical" |
group, separator |
Accessibility
- role="group" with aria-orientation; name it with label or aria-labelledby.
- Every member stays its own tab stop. For one tab stop with arrow keys, use ToggleGroup.
- A hovered or focused member is raised so its border and focus ring are never hidden by a neighbour.
See also
- Button (opens in a new tab): A button or a link that looks like one, in six variants and four sizes.
- Input (opens in a new tab): A native text input in the theme's control chrome, with a two-way value.
- InputGroup (opens in a new tab): An Input or Textarea with icons, text and buttons inside one box.
- Textarea (opens in a new tab): A native multi-line input that grows with its content, between rows and maxRows.
- Field (opens in a new tab): A label, a control, a description and an error wired together, with native validation that never moves the layout.
- Label (opens in a new tab): A native label for a control. The label dims when its control is disabled.