Component size, gzipped: 21kb

Button Group

API

Groups a collection of similar actions together.

When to use

  • If you need to emphasize context of similar actions.
  • If a single option or multiple options of the set may be selected.

Examples

Basic usage

With icons

With enhancers

Radio mode

In radio mode, the button group functions similarly to a radio group. Only one button can be "selected" at a time.

Checkbox mode

In checkbox mode, the button group functions similarly to a group of checkboxes. Multiple buttons can be "selected" at the same time.

Disabled button group

You can disable the entire button group as in the example above. Or you can disable isolated buttons as in the example below.

Single disabled button

With a dropdown

Stateful (uncontrolled) with radio mode

As with many of our components, there is also an uncontrolled version, StatefulButtonGroup, which manages its own state. If mode is set to radio or checkbox, this stateful version of the component will adapt to keep track of the selected value(s).

Stateful (uncontrolled) with checkbox mode

API

ButtonGroup props

NameTypeDescription
children
Buttons within the group
disabled
Indicates that the button group is disabled
mode
Changes keyboard shortcuts and role attributes. The actual onClick update implementation is up to you.
onClick
Function called when any button is clicked.
overrides
Lets you customize all aspects of the component.
selected
Defines which buttons are selected
shape
Defines the shape of the button in the button group.
size
Defines the size of the button.

ButtonGroup exports

You can import this module like so:

import {ButtonGroup} from 'baseui/button-group'

It exports the following components or utility functions: