Button Group
Button groups combine related buttons into a single visual unit. Use them for toolbars, segmented controls, or any set of actions that belong together.
Give every button group a label.
It isn't shown on screen, but assistive devices announce it so people know what the grouped buttons control.
Examples
Orientation
Set the orientation attribute to vertical to stack the buttons instead of placing them side by side.
Pill
Add the pill attribute to each button to round the group's outer edges.
Dropdowns
Place a dropdown anywhere in the group to attach a menu of related actions.
Split Buttons
Pair a primary button with a dropdown to make a split button. Give the dropdown trigger an accessible label so people using assistive devices know what it opens.
Tooltips
Pair each button with a tooltip to explain what it does on hover and focus.
Toolbars
Combine several button groups into a toolbar of related action sets. Use icon-only buttons with label for compact controls, and tooltips to name each one.
Native Buttons
Button groups also work with native <button> elements when Native Styles are included.
API
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.
Import this component directly from the CDN:
import 'https://ka-f.webawesome.com/[email protected]/components/button-group/button-group.js';
After installing Web Awesome via npm, import this component:
import '@awesome.me/webawesome/dist/components/button-group/button-group.js';
If you're self-hosting Web Awesome, import this component from your server:
import './webawesome/dist/components/button-group/button-group.js';
To import this component for React 18 or below, use the following code:
import WaButtonGroup from '@awesome.me/webawesome/dist/react/button-group/index.js';
Slots
Learn more about using slots.
| Name | Description |
|---|---|
| (default) | One or more <wa-button> elements to display in the button group. |
Attributes & Properties
Learn more about attributes and properties.
| Name | Description | Reflects |
|---|---|---|
labellabel |
A label to use for the button group. This won't be displayed on the screen, but it will be announced by assistive
devices when interacting with the control and is strongly recommended.
Type
string
Default
''
|
|
orientationorientation |
The button group's orientation.
Type
'horizontal' | 'vertical'
Default
'horizontal'
|
|
CSS Parts
Learn more about CSS parts.
| Name | Description | CSS selector |
|---|---|---|
button-group |
The component's outer wrapper. |
::part(button-group)
|
base |
Deprecated. Use the button-group part instead. |
::part(base)
|