Skip to content

ToggleButtonGroup

A ToggleButtonGroup is a group of ToggleButtons that allows users to select one or multiple buttons from the group.

Guidelines

Using toggle button groups

Buttons within the toggle button group must carry a label. In the case of icon-only buttons, the label will be available only to screen reader users.

Use the ToggleButtonGroup when you require users to select either one or multiple options from a group. If you want users to choose from a set of actions, with the restriction that only one can be active simultaneously, use the ButtonGroup instead.

Example of a Codex ToggleButtonGroup.

Specifications

Specification of ToggleButtonGroup.

A toggle button group consists of normal (framed) buttons, which may include the following elements:

  1. Icon (optional)
    Icons simplify user recognition and provide the ability to shorten button labels to a minimum.
  2. Label
    Button labels should be as short as possible, with text that clearly states what option will be selected when the button is toggled on.
  3. White line
    For toggled-on buttons, a white line is added to visually separate them, whether they are on the same line or placed on different rows in the stacked version.

Refer to the ToggleButtonGroup component in Codex Figma.

Stacked buttons

When the ToggleButtonGroup exceeds the available space on a single line, the buttons will wrap onto the next line.

Example of a ToggleButtonGroup with stacked buttons in two lines.

Interaction states

ToggleButtonGroups have the following visually separate states:

Interaction states of ToggleButtonGroup, affecting the buttons within the group: default, hover, active, focus, selected, disabled, selected-hover, selected-active, selected-focus, two buttons selected, all buttons selected, and all buttons disabled.

  1. Default
  2. Hover on one button
  3. Active button
  4. Focus on one button
  5. One button is selected
  6. One button is disabled
  7. Hover on the selected button
  8. The selected button is active
  9. Focus on the selected button
  10. Two buttons are selected
  11. All buttons are selected
  12. All buttons are disabled

Demos

Single value

To allow only a single value to be selected, initialize v-model to null.

Selected value: (null)

NameValue
View
Reading direction

Initially selected single value

To start with one button already selected, initialize v-model to that value.

Use the icon property to add an icon before the text of a button. Use the disabled property to disable individual buttons. For more information on how to control the appearance of each button, see the ButtonGroup documentation.

Selected value: framed

Multiple values

To allow multiple values to be selected, initialize v-model to an empty array ([]). To start with some of buttons already selected, initialize v-model to an array of the values of those buttons.

Selected values: (none)

Disabled

The entire component can be disabled by setting the disabled prop. Individual buttons can be disabled by setting their .disabled property.

Overflowing buttons

When the button group is too large to fit on one line, the buttons overflow to the next line.

Selected values: (none)

Custom button display

The contents of the buttons can be customized using the default slot. The ButtonGroupItem object for each button is available through the button binding, and the selected state of each button is available through the selected binding. In this example, the value of the button is displayed after its label, but only if the button is selected.

Selected value: 2

Vue usage

Whether the group is single-select or multi-select is automatically detected based on the value bound to v-model: if it's an array, the group allows multiple selections; otherwise, it only allows a single selection. To initially select nothing, initialize the v-model value to null (for single-select groups) or [] (for multi-select groups).

Props

Prop nameDescriptionTypeDefault
buttons(required)Buttons to display. See the ButtonGroupItem type.ButtonGroupItem[]
modelValue(required)Selected value, or array of selected values.

If this is a string or number, the button whose value equals that string or number is selected, and only a single selection is allowed. If this is an array, the buttons whose values equal any of the values in the array are selected, and multiple selections are allowed. To select none of the buttons initially, set this to null (for single-selection groups) or to [] (for multi-selection groups).

Must be bound with v-model.
string|number|null|( string|number )[]
disabledWhether the entire group is disabled.

If this is set to true, all buttons in the group are disabled. Buttons can also be disabled individually by setting their disabled property to true.
booleanfalse

Events

Event namePropertiesDescription
update:modelValuemodelValue string|number|( string|number )[] - The new model valueEmitted when modelValue changes.

Slots

NameDescriptionBindings
defaultContent of an individual buttonbutton ButtonGroupItem - Object describing the button to display
selected boolean - Whether the button is selected