Skip to main content

Group

Visually joined buttons that act as a single control. A group collapses the gap between adjacent buttons so they read as one segmented control - useful for view switchers, toolbars, and exclusive or multi-select toggle sets. The group is purely visual; each child remains a fully accessible button.

Render a <div role="group"> wrapper around pre-rendered child HTML.

The group component is CSS only, consumers write their own markup. This inline helper is a stand-in used exclusively by the stories so controls (classes, attributes) flow through to a deterministic DOM shape for interaction tests.

Usage​

When to use

  • To present a set of related actions as a segmented control (e.g. view switcher, zoom level, alignment)
  • To offer a toggle set where one option can be active at a time
  • To group closely related utility actions in a toolbar

When not to use

  • To group unrelated actions - use standalone buttons with spacing
  • To group form inputs - use fieldset
  • To attach a button to an input - use addon

Do

  • Keep labels in a group short and consistent in length
  • Use aria-pressed on toggle buttons to communicate active state
  • Label the group itself via aria-label or a visible heading

Don't

  • Don't mix unrelated actions in a single group
  • Don't rely on active-state color alone - pair it with aria-pressed
  • Don't group more buttons than comfortably fit on the smallest supported viewport

API​

Slots​

SlotRequiredDescription
content-Controls rendered inside the group - typically buttons, optionally mixed with other inline elements.

Props​

PropTypeDefaultDescription
classesarray-Additional CSS class words merged into the root element.
attributesobject-Additional HTML attributes spread on the root element. Pass aria-label here to name the group.

Classes​

ClassCapabilityDefaultDescription
.smSize-Small.
.mdSizeYesMedium.
.lgSize-Large.
.verticalOrientation-Children flow along the vertical axis.

Examples​

Horizontal​

Buttons joined horizontally as a single segmented control.

Vertical​

Buttons joined vertically for compact toolbars or sidebars.

Toggle​

Toggle buttons with aria-pressed communicating active state.

Sizes​

Small and large size variants.

Accessibility​

  • WCAG 2.2 AA
  • The group container carries role="group" with an aria-label
  • Toggle buttons use aria-pressed="true" / "false" for active state
  • Every child button remains keyboard reachable
  • Visible focus indicator on each child button
  • button - base button component
  • fieldset - semantic grouping of form controls
  • addon - input with attached elements