-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #813 from trimble-oss/button-groups-in-style-guide
Added button groups guidelines
- Loading branch information
Showing
10 changed files
with
312 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
title: "Button Groups" | ||
layout: "single" | ||
description: "Button groups allow selection from a similar or related set of options." | ||
components: true | ||
componentsWeb: true | ||
images: | ||
- "/img/components/headers/button-group.png" | ||
# bootstrapURL: "/components/button-group/" | ||
tags: [usage] | ||
aliases: | ||
- "/components/web/button-group/" | ||
--- | ||
|
||
## Overview | ||
|
||
A button group is used to organize related actions and allow selection and toggling. Buttons can be grouped in a single line or in a vertical column. They can be used within action bars (e.g. [Toolbar](/components/web/toolbar/)). | ||
|
||
<div class="btn-group" role="group" aria-label="Basic radio toggle button group"> | ||
<input type="radio" class="btn-check" name="btnRadioIcon" id="btnRadioIcon1" autocomplete="off" checked> | ||
<label class="btn btn-outline-primary btn-icon-only" for="btnRadioIcon1"> | ||
<svg width="24" height="24" fill="currentColor"> | ||
<use xlink:href="/modus-solid-icons.svg#wifi" /></svg> | ||
</label> | ||
<input type="radio" class="btn-check" name="btnRadioIcon" id="btnRadioIcon2" autocomplete="off"> | ||
<label class="btn btn-outline-primary btn-icon-only" for="btnRadioIcon2"> | ||
<svg width="24" height="24" fill="currentColor"> | ||
<use xlink:href="/modus-solid-icons.svg#wifi-off" /></svg> | ||
</label> | ||
<input type="radio" class="btn-check" name="btnRadioIcon" id="btnRadioIcon3" autocomplete="off"> | ||
<label class="btn btn-outline-primary btn-icon-only" for="btnRadioIcon3"> | ||
<svg width="24" height="24" fill="currentColor"> | ||
<use xlink:href="/modus-solid-icons.svg#wifi-no-internet" /></svg> | ||
</label> | ||
</div> | ||
|
||
<style> | ||
.btn-group:not(.btn-group-sm):not(.btn-group-lg) label.btn-icon-only { | ||
padding-top: 2px; | ||
padding-right: .25rem!important; | ||
padding-left: .25rem!important; | ||
} | ||
</style> | ||
|
||
## Usage | ||
|
||
### Use when | ||
|
||
- Organizing similar functionality of 2-5 actions. | ||
- You need to show the selected action or states with contextual relationships. | ||
- Grouping related actions or states. | ||
- Stepping through linear content (e.g. Wizards). | ||
|
||
### Don’t use when | ||
|
||
- Actions represented by buttons are not related. | ||
- Mixing destructive and non-destructive actions. | ||
- Button labels do not appropriately describe the actions within one or two words. Instead use Links. | ||
- You need to navigate through content on the page. Instead, use [Tabs](/components/web/tabs/). | ||
- You have more than 5 options so as not to overwhelm the user with too many choices. | ||
|
||
## Types | ||
|
||
Button groups support two layout directions: **horizontal** and **vertical** | ||
|
||
### Horizontal Button Group | ||
|
||
<div class="btn-group" role="group" aria-label="Basic radio toggle button group"> | ||
<input type="radio" class="btn-check" name="btnRadio" id="btnRadio1" autocomplete="off" checked> | ||
<label class="btn btn-outline-primary" for="btnRadio1">Radio 1</label> | ||
|
||
<input type="radio" class="btn-check" name="btnRadio" id="btnRadio2" autocomplete="off"> | ||
<label class="btn btn-outline-primary" for="btnRadio2">Radio 2</label> | ||
|
||
<input type="radio" class="btn-check" name="btnRadio" id="btnRadio3" autocomplete="off"> | ||
<label class="btn btn-outline-primary" for="btnRadio3">Radio 3</label> | ||
</div> | ||
<br><br> | ||
|
||
### Vertical Button Group | ||
|
||
<div class="btn-group-vertical" role="group" aria-label="Vertical radio toggle button group"> | ||
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio1" autocomplete="off" checked> | ||
<label class="btn btn-outline-primary" for="vbtn-radio1">Radio 1</label> | ||
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio2" autocomplete="off"> | ||
<label class="btn btn-outline-primary" for="vbtn-radio2">Radio 2</label> | ||
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio3" autocomplete="off"> | ||
<label class="btn btn-outline-primary" for="vbtn-radio3">Radio 3</label> | ||
</div> | ||
|
||
{{< whats-changed-table >}} | ||
|
||
| Date | Version | Notes | Contributors | | ||
| ---------- | ------- | -------------------- | ---------------------------------------- | | ||
| 02/14/2024 | 1.0.0 | New component added. | E. Gunther, E. Nowak, C. Oliff, C.Winsor | | ||
|
||
{{</ whats-changed-table >}} |
9 changes: 5 additions & 4 deletions
9
...ponents/web/button-group/accessibility.md → ...onents/web/button-groups/accessibility.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
--- | ||
title: "Button group" | ||
title: "Button Groups" | ||
layout: "single" | ||
description: "Group a series of buttons together on a single line." | ||
description: "Button groups allow selection from a similar or related set of options." | ||
components: true | ||
componentsWeb: true | ||
images: | ||
- "/img/components/headers/button-group.png" | ||
# bootstrapURL: "/components/button-group/" | ||
component: button-group | ||
tags: [accessibility] | ||
hidden: true | ||
private: true | ||
--- | ||
|
||
## Accessibility | ||
|
||
- Button groups require an appropriate role attribute and explicit label to ensure assistive technologies like screen readers identify buttons as grouped and announce them. Use `role="group"` for button groups or `role="toolbar"` for button toolbars. | ||
- Use `aria-label` or `aria-labelledby` to label them. | ||
- Use the `<button type="button">` element. Don’t use `<a>` or `<span>` because screen readers won’t recognize it as a usable button. | ||
- Make sure all the buttons within the button group are focusable and part of a linear tabbing sequence. | ||
- When using an icon-only button group, each button must have a [Tooltip](/components/web/tooltips/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.