On This Page...
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.
< wa-button-group label = " Alignment" >
< wa-button appearance = " filled" > Left</ wa-button>
< wa-button appearance = " filled" > Center</ wa-button>
< wa-button appearance = " filled" > Right</ wa-button>
</ wa-button-group>
Code
Edit
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
Link to This Section
Orientation
Link to This Section
Set the orientation attribute to vertical to stack the buttons instead of placing them side by side.
< wa-button-group orientation = " vertical" label = " Options" >
< wa-button appearance = " filled" > Top</ wa-button>
< wa-button appearance = " filled" > Middle</ wa-button>
< wa-button appearance = " filled" > Bottom</ wa-button>
</ wa-button-group>
Code
Edit
Pill
Link to This Section
Add the pill attribute to each button to round the group's outer edges.
< wa-button-group label = " Alignment" >
< wa-button appearance = " filled" size = " m" pill > Left</ wa-button>
< wa-button appearance = " filled" size = " m" pill > Center</ wa-button>
< wa-button appearance = " filled" size = " m" pill > Right</ wa-button>
</ wa-button-group>
Code
Edit
Dropdowns
Link to This Section
Place a dropdown anywhere in the group to attach a menu of related actions.
Edit
More
Cut
Copy
Paste
Delete
< wa-button-group label = " Options" >
< wa-button appearance = " filled" > Edit</ wa-button>
< wa-dropdown>
< wa-button appearance = " filled" slot = " trigger" with-caret > More</ wa-button>
< wa-dropdown-item> Cut</ wa-dropdown-item>
< wa-dropdown-item> Copy</ wa-dropdown-item>
< wa-dropdown-item> Paste</ wa-dropdown-item>
</ wa-dropdown>
< wa-button appearance = " filled" > Delete</ wa-button>
</ wa-button-group>
Code
Edit
Link to This Section
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.
Save
Save
Save as…
Save all
< wa-button-group label = " Save" >
< wa-button appearance = " filled" variant = " brand" > Save</ wa-button>
< wa-dropdown placement = " bottom-end" >
< wa-button appearance = " filled" slot = " trigger" variant = " brand" >
< wa-icon name = " chevron-down" label = " More options" > </ wa-icon>
</ wa-button>
< wa-dropdown-item> Save</ wa-dropdown-item>
< wa-dropdown-item> Save as… </ wa-dropdown-item>
< wa-dropdown-item> Save all</ wa-dropdown-item>
</ wa-dropdown>
</ wa-button-group>
Code
Edit
Link to This Section
Pair each button with a tooltip to explain what it does on hover and focus.
Left
Center
Right
Align left
Align center
Align right
< wa-button-group label = " Alignment" >
< wa-button appearance = " filled" id = " button-left" > Left</ wa-button>
< wa-button appearance = " filled" id = " button-center" > Center</ wa-button>
< wa-button appearance = " filled" id = " button-right" > Right</ wa-button>
</ wa-button-group>
< wa-tooltip for = " button-left" > Align left</ wa-tooltip>
< wa-tooltip for = " button-center" > Align center</ wa-tooltip>
< wa-tooltip for = " button-right" > Align right</ wa-tooltip>
Code
Edit
Link to This Section
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.
Undo
Redo
Bold
Italic
Underline
Align left
Align center
Align right
< div class = " button-group-toolbar wa-cluster" >
< wa-button-group label = " History" >
< wa-button appearance = " filled" id = " undo-button"
> < wa-icon name = " undo" variant = " solid" label = " Undo" > </ wa-icon
> </ wa-button>
< wa-button appearance = " filled" id = " redo-button"
> < wa-icon name = " redo" variant = " solid" label = " Redo" > </ wa-icon
> </ wa-button>
</ wa-button-group>
< wa-button-group label = " Formatting" >
< wa-button appearance = " filled" id = " button-bold"
> < wa-icon name = " bold" variant = " solid" label = " Bold" > </ wa-icon
> </ wa-button>
< wa-button appearance = " filled" id = " button-italic"
> < wa-icon name = " italic" variant = " solid" label = " Italic" > </ wa-icon
> </ wa-button>
< wa-button appearance = " filled" id = " button-underline"
> < wa-icon name = " underline" variant = " solid" label = " Underline" > </ wa-icon
> </ wa-button>
</ wa-button-group>
< wa-button-group label = " Alignment" >
< wa-button appearance = " filled" id = " button-align-left"
> < wa-icon name = " align-left" variant = " solid" label = " Align left" > </ wa-icon
> </ wa-button>
< wa-button appearance = " filled" id = " button-align-center"
> < wa-icon name = " align-center" variant = " solid" label = " Align center" > </ wa-icon
> </ wa-button>
< wa-button appearance = " filled" id = " button-align-right"
> < wa-icon name = " align-right" variant = " solid" label = " Align right" > </ wa-icon
> </ wa-button>
</ wa-button-group>
</ div>
< wa-tooltip for = " undo-button" > Undo</ wa-tooltip>
< wa-tooltip for = " redo-button" > Redo</ wa-tooltip>
< wa-tooltip for = " button-bold" > Bold</ wa-tooltip>
< wa-tooltip for = " button-italic" > Italic</ wa-tooltip>
< wa-tooltip for = " button-underline" > Underline</ wa-tooltip>
< wa-tooltip for = " button-align-left" > Align left</ wa-tooltip>
< wa-tooltip for = " button-align-center" > Align center</ wa-tooltip>
< wa-tooltip for = " button-align-right" > Align right</ wa-tooltip>
Code
Edit
Link to This Section
Button groups also work with native <button> elements when Native Styles are included.
< wa-button-group label = " Alignment" >
< button class = " wa-filled" > Left</ button>
< button class = " wa-filled" > Center</ button>
< button class = " wa-filled" > Right</ button>
</ wa-button-group>
Code
Edit
API
Link to This Section
Importing
Link to This Section
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.
CDN
npm
Self-Hosted
React
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
Link to This Section
Learn more about using slots .
Name
Description
(default)
One or more <wa-button> elements to display in the button group.
Attributes & Properties
Link to This Section
Learn more about attributes and properties .
Name
Description
Reflects
label
label
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 ''
orientation
orientation
The button group's orientation.
Type 'horizontal' | 'vertical'
Default 'horizontal'
CSS Parts
Link to This Section
Learn more about CSS parts .
Name
Description
CSS selector
base
The component's base wrapper.
::part(base)
Need a hand?
Report a bug
Ask for help