Overview
Button Group is a layout component that arranges multiple related buttons in a horizontal or wrapped layout. It can display buttons as separate elements with spacing or as an attached group where buttons are visually connected.Installation
Button Group requires the Button component:
Usage
Default Button Group
By default, buttons are displayed separately with consistent spacing.Attached Button Group
Attached button groups visually connect buttons together, useful for segmented controls or toolbars.Justify Content
Control the horizontal alignment of buttons within the group (unattached only).Toggle Button Group
Create toggle button groups using the pressed prop on secondary buttons.With Icon Buttons
Props
ButtonGroup Props
| Prop | Type | Default | Description |
|---|---|---|---|
| attached | boolean | false | Visually connects buttons together |
| justifyContent | 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'flex-start' | Horizontal alignment (unattached only) |
| element | string | 'BUTTON_GROUP' | Customization element name |
| children | ReactNode | - | Button components (required) |
Best Practices
Do
- Group related buttons that perform related actions
- Use attached groups for toggle or segmented controls
- Place primary action buttons on the right in left-to-right languages
- Use consistent button sizes within a group
- Limit the number of buttons in a group (typically 2-5)
- Use justifyContent to align buttons appropriately for the context
Don’t
- Don’t mix different button sizes in the same group
- Don’t use attached groups for unrelated actions
- Don’t put too many buttons in a single group
- Don’t use multiple primary buttons in a group
- Don’t nest button groups
- Don’t use fullWidth buttons in button groups
Composition Guidelines
Form ActionsAccessibility
- Button Group sets role=“group” on the container
- Individual buttons maintain their own keyboard navigation and focus states
- In attached groups, z-index management ensures focus indicators are always visible
- Use aria-label on the ButtonGroup if the grouping needs additional context
- Toggle buttons should use aria-pressed to indicate state