Button Group
The Button Group combines a set of related buttons.
Introduction
The Button Group component combines a set of buttons that have similar or related functionality.
<ButtonGroup>
<Button />
...
<IconButton />
</ButtonGroup>
Playground
Basics
The Button Group component can wrap Button
and IconButton
.
Customization
Variants
The Button Group component supports Joy UI's four global variants: outlined
(default), solid
, soft
, and plain
.
The variant
prop is passed to the buttons, not the Button Group itself.
Colors
Every palette included in the theme is available via the color
prop.
Play around combining different colors with different variants.
Disabled
Use the disabled
prop to disable all the buttons.
Note that if you explicitly specify the disabled
prop on the buttons directly, it will override what is used in the Button Group.
Spacing
Use spacing
prop to control the gap between buttons. If the spacing
is set to 0
(by default), the radius of the buttons will be adjusted to form a continuous surface.
Vertical group
The Button Group component can be displayed vertically using the orientation="horizontal"
prop.
Note that this prop has no effect on IconButton
component.
Stretching button
Use the buttonFlex
prop to make the buttons fill the available space of the Button Group component.
Minimum width
For a large container, control the default width of the buttons by providing a valid CSS flex
value to the buttonFlex
prop.
Title
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Split button
The Button Group component can also be used to create a split button. The dropdown can change the button action (as in this example) or be used to immediately trigger a related action.
Separator color
When the Button Group's variant is not outlined
, separators are created between buttons.
To control the color of the separator, override the CSS variable --ButtonGroup-separatorColor
via the sx
prop.
Using it with a Tooltip
The Button Group component supports arbitrary children that wrap the buttons by preserving the same appearance.
Common examples
Pill button group
Use the CSS variable --ButtonGroup-radius
to control the radius of the start and end buttons.
Custom separator
This example uses the Divider
component to create a custom separator between the buttons.
The CSS variable --ButtonGroup-separatorColor
is then set with an arbitrary value to remove the default separator.