You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]>
Copy file name to clipboardExpand all lines: content/components/button-group.mdx
+10-2Lines changed: 10 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ Grouping buttons with a button group is better than rendering buttons close toge
38
38
- 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.
39
39
- Avoid grouping too many buttons together. It could be overwhelming to the user.
40
40
- 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:linktoTabNavonceit'smerged-->
41
+
- Do not use a button group as a replacement for [tab navigation](/components/tab-nav).
42
42
- 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.
43
43
- Do not group an [invisible](/components/button#invisible) button with buttons of another variant.
44
44
@@ -79,7 +79,15 @@ Similarly to buttons, button segments can optionally include an icon and/or a co
79
79
80
80
## Accessibility
81
81
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.
0 commit comments