Skip to content

Commit dc369ba

Browse files
docs(ButtonGroup): add guidance around toolbar role (#888)
* docs(ButtonGroup): add guidance around toolbar role * Update content/components/button-group.mdx Co-authored-by: Patrick H. Lauke <[email protected]> * Docs(ButtonGroup): add note on PRC implementation and fix todo --------- Co-authored-by: Patrick H. Lauke <[email protected]>
1 parent b0bc438 commit dc369ba

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

content/components/button-group.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Grouping buttons with a button group is better than rendering buttons close toge
3838
- For most use-cases, only default button types should be used in button groups. In rare cases, primary buttons can be included in button groups but there should only ever be one primary button (if any) in a button group.
3939
- Avoid grouping too many buttons together. It could be overwhelming to the user.
4040
- Do not use a button group to indicate a selection. Use a [segmented control](/components/segmented-control) instead.
41-
- Do not use a button group as a replacement for tab navigation. <!-- TODO: link to TabNav once it's merged -->
41+
- Do not use a button group as a replacement for [tab navigation](/components/tab-nav).
4242
- Avoid mixing buttons with text labels with icon-only buttons. However, it is acceptable to group a text-labeled button with an icon-only button with a [down-pointing triangle](https://primer.style/foundations/icons/triangle-down-16) that opens a dropdown menu of actions related to the button.
4343
- Do not group an [invisible](/components/button#invisible) button with buttons of another variant.
4444

@@ -79,7 +79,15 @@ Similarly to buttons, button segments can optionally include an icon and/or a co
7979

8080
## Accessibility
8181

82-
A button group does not behave like a [toolbar](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/toolbar_role), so assistive technologies still interpret the buttons as unrelated. The grouping is purely visual.
82+
### As toolbar
83+
84+
By default, a button group does not behave like a [toolbar](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/toolbar_role), so assistive technologies still interpret the buttons as unrelated. The grouping is purely visual.
85+
86+
If you want to make the button group behave like a toolbar, you can add the `role="toolbar"` prop to the `ButtonGroup` component. This will communicate the appropriate role to assistive technologies.
87+
88+
When `role="toolbar"` is used, individual buttons aren't separately focusable. Instead, only one button receives focus, and users switch between all buttons in the toolbar using the cursor keys. This behavior is baked into the component.
89+
90+
Please note the toolbar keyboard interaction behaviors are currently implemented in Primer React only, and are not available in Primer View Components.
8391

8492
### Descriptive buttons
8593

0 commit comments

Comments
 (0)