ButtonGroup
BasicActions
<co-button-group>ButtonGroup lays out related buttons with the 8px gap the screens use, or joins them into one attached control.
import { ButtonGroup } from 'health-components';
Examples
Showcase
Attached
Footer End
Usage
<ButtonGroup align="end">
<Button onClick={cancel}>Cancel</Button>
<Button variant="primary" onClick={save}>Save Changes</Button>
</ButtonGroup>
When to use
- Page header actions: "Care gaps (3 open)", "Outside records (HIE)", "For developers".
- Modal footers, right aligned (
align="end"). - Attached: a small view switch such as Day, Week, Month on the calendar.
When not to use
- Choosing one value from a set inside a form: use SegmentedControl, which is a radio group.
Variants and states
| Variant | What it is |
|---|---|
| default | Buttons with 8px gaps, wraps on narrow screens. |
| attached | Joined borders, no gap. |
| align end | Right aligned, for footers. |
Accessibility
- The group has role group; give it a label when the buttons only make sense together.
- Primary goes last in a footer, so the reading order ends on the main action.
Do and don't
- Do: Footer: Cancel, then Save Changes.
- Don't: More than four buttons in a header: move the rest into a SplitButton or KebabMenu.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
attached | boolean | false | Joins the buttons into one attached control (Day / Week / Month) |
align | 'start' | 'end' | 'start' | 'start' | 'end': 'end' right-aligns a footer |
label | string | none | aria-label of the group |
children * | ReactNode | — | Buttons; required |
Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-button-group>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.
Angular template
<co-button-group attached align="…" [defaultValue]="defaultValue">…</co-button-group>
| Kind | Name | Description |
|---|---|---|
| attribute | attached | Joins the buttons into one attached control (Day / Week / Month); default false |
| attribute | align | 'start' | 'end': 'end' right-aligns a footer; default 'start' |
| attribute | label | aria-label of the group; default none |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| slot | (default) | Buttons; required |