A button group is a row of joined System buttons for choosing between two to four short options. The selected button has a black 12% fill.
How to add a button group to a page. The file is components/css/button-group.css.
Link the shared stylesheet once per page. Never copy the rules into a page.
| Step | What to do |
|---|---|
| 1. Link | <link rel="stylesheet" href="/components/css/button-group.css">. Both templates already have it. |
| 2. Markup | A div.btn-group[role="group"] with an accessible name, and one button per option. |
| 3. Selected | Set aria-pressed="true" on one button and "false" on the others. |
| 4. Select one | Your script moves aria-pressed on click. The CSS does not. |
| 5. Focus ring | Add the small script that sets body.keyboard-nav on Tab, as for the Button. |
| Class | Use |
|---|---|
btn-group | The group. The buttons inside are styled by the group, with no class of their own. |
[data-state] selectors do nothing outside the documentation pages.The component is one CSS file, shared by every page. Link it, never copy it. The CSS below is read from the file the page links, so it is always what you see.