Skip to content

Button Group

The group flattens the inner corners and collapses the shared edges to a single border, so the controls read as one object.

ClassPart
.button-groupThe container
.button-group-textA non-interactive label sharing the group’s shape
.button-group-separatorA divider between segments
AttributeMeaning
data-orientation="vertical"Stacks the controls instead of placing them in a row

.button-group-text is for a prefix or suffix that is not a control — a scheme, a unit, a currency.

https://

Use a separator when the segments do different things, rather than being choices of one kind.

Set dir="rtl" on the page or on any subtree — padding, corners and positions follow the reading direction on their own. See the button page for a live example.

A group of related controls should say so. Add role="group" and a name:

<div class="button-group" role="group" aria-label="Text alignment">

When the buttons are choices rather than actions, they are a radio group, not a button group — reach for role="radiogroup" with radio inputs so the arrow keys and the announced state come from the platform.

Focus is never hidden by a neighbour: a focused control lifts above the others so its ring stays whole.