Skip to content

Button group

BetaActionsOpen in the workshop

Several actions on one object, joined: export formats, chart views, row actions.

.xg-btn-group > .xg-btn.xg-btn--secondary

Example and markup

Live, from xg-ui.css and xg-ui.js. Switch the brand and mode on the example itself, or for the whole site in the header.

Button group
Markup
<div class="xg-btn-group" role="group" aria-label="Export">
<button class="xg-btn xg-btn--secondary xg-btn--sm" type="button">CSV</button>
<button class="xg-btn xg-btn--secondary xg-btn--sm" type="button">XLSX</button>
<button class="xg-btn xg-btn--secondary xg-btn--sm" type="button">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<rect x="8" y="8" width="13" height="13" rx="2"/>
<path d="M16 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3"/>
</svg>Copy link</button>
</div>

States

Hover, focus and pressed are forced here with .is-hover, .is-focus and .is-active so they can be seen side by side; in a product they come from :hover, :focus-visible and :active.

Button group: every state
StateGroup
Default
Hover on one
Focus on one

When to use it

Use it for

two to four related actions that act on the same thing.

Not for

choosing one value from a set (use Segmented control); unrelated actions.

Rules

  • Same variant and size for every button in the group; secondary is the norm.
  • Never mix a primary into a group.

Accessibility

  • Wrap in role="group" with aria-label when the group has no visible heading.

Every color pair this component uses is measured for both brands in light and dark on the Accessibility page.

Also in Actions: Button, Icon button, Link.

Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).