Skip to main content

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​

Storybook

Attached​

Storybook
Storybook

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​

VariantWhat it is
defaultButtons with 8px gaps, wraps on narrow screens.
attachedJoined borders, no gap.
align endRight 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​

PropTypeDefaultDescription
attachedbooleanfalseJoins the buttons into one attached control (Day / Week / Month)
align'start' | 'end''start''start' | 'end': 'end' right-aligns a footer
labelstringnonearia-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>
KindNameDescription
attributeattachedJoins the buttons into one attached control (Day / Week / Month); default false
attributealign'start' | 'end': 'end' right-aligns a footer; default 'start'
attributelabelaria-label of the group; default none
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
slot(default)Buttons; required