Use Buttonbar...
- To pick one choice from a linear set of closely related choices (such as βFrontβ and βBackβ) and immediately apply that selection.
- To select between 2-5 choices.
- As a toggle control when the choices are not βonβ or βoffβ.
Don't use Buttonbar...
- As a form of navigation.
- To select more than 6+ choices, as this can be difficult to parse and take up too much horizontal space. Use a Dropdown or Listbox instead.
- As a toggle control when the choices are βonβ or βoffβ. Use a Toggle Switch instead.
Width
Use width="full-width" to grow a Buttonbar to fill its container.
The preview has been updated.
Single-Select
Use single-select when you want only one value to be selected at a time. The Buttonbar will act as a set of radio buttons.
The preview has been updated.
To set a default state:
- In the React API, use
defaultSelectedValueon theButtonbarto specify an initial state. - In the Vanilla API, put a
checkedproperty onto the radio button that should be selected by default.
To control the state of the React API Buttonbar component, use the selectedValue and onSelectedValueChange props. onSelectedValueChangeΒ will be invoked with the new value as the first argument and the actualΒ <input>Β event as the second argument in case you need it.
The preview has been updated.
Multi-Select
Use multi-select when you want to allow multiple options to be selected at the same time. The Buttonbar will act as a series of checkboxes.
The preview has been updated.
To set a default state:
- In the React API, use
defaultSelectedValueson theButtonbarto specify an initial state. - In the Vanilla API, put a
checkedproperty onto the radio button that should be selected by default.
To control the state of the React API Buttonbar component, use the selectedValues and onSelectedValuesChange props. selectedValuesΒ is an array of selected values. onSelectedValuesChangeΒ will be invoked with an updated array of selected values as the first argument and the actualΒ <input>Β event as the second argument in case you need it.
The preview has been updated.
Toolbar
Use toolbar when you want to display a series of secondary Buttons.
The preview has been updated.
Disabled
Use disabled on ButtonbarButton when its option is unavailable.
The preview has been updated.
Implementation
- A
<fieldset>Β tag cannot be used because styling of that tag is not supported enough in Chrome.
Accessibility
- Include an
aria-labelwhose value is a localized description of what the buttonbar is or does, e.g. "Change view". - If the Buttonbar controls another section of the page, include an
aria-controlsattribute whose value is the id of the section it controls.