Installation
- CLI
- Manual
Usage
Accessibility
- The
ButtonGroupcomponent has theroleattribute set togroup. - Use
tabindexto navigate between the buttons in the group. - Use
aria-labeloraria-labelledbyto label the button group.
ButtonGroup vs ToggleGroup
- Use the
ButtonGroupcomponent when you want to group buttons that perform an action. - Use the
ToggleGroupcomponent when you want to group buttons that toggle a state.
Examples
Orientation
Set theorientation prop to change the button group layout.
Size
Control the size of buttons using thesize prop on individual buttons.
Nested
NestButtonGroup components to create button groups with spacing.
Separator
TheButtonGroupSeparator component visually divides buttons within a group.
Buttons with variant outline do not need a separator since they have a border. For other variants, a separator is recommended to improve the visual hierarchy.
Split
Create a split button group by adding two buttons separated by aButtonGroupSeparator.
Input
Wrap anInput component with buttons.
Input Group
Wrap anInputGroup component to create complex input layouts.
Dropdown Menu
Create a split button group with aDropdownMenu component.
Select
Pair with aSelect component.
Popover
Use with aPopover component.