Skip to content

Commit 0876914

Browse files
authored
Some copy edits and do/dont updates (primer#274)
* Some copy edits and do/dont updates * update buttons title and url in index * Update nav.yml * Rename button-purpose.mdx to descriptive-buttons.mdx
1 parent fe3d8d9 commit 0876914

File tree

3 files changed

+53
-54
lines changed

3 files changed

+53
-54
lines changed

content/accessibility/button-purpose.mdx renamed to content/accessibility/descriptive-buttons.mdx

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ In order for a button’s purpose to be clear to all users, it must have a meani
88

99
### What is a meaningful name?
1010

11-
A meaningful name describes the button’s purpose: The action that occurs when the button is activated (e.g. removing a list item), and the action’s associated context (e.g. the specific item to be removed). To avoid unnecessary verbosity, button names should be as succinct as possible while still being descriptive and unique. Refer to [Identifying comments](#identifying-comments) below for an example of a succinct, unique name.
11+
A meaningful name describes the button’s purpose: the action that occurs when the button is activated (for example: removing a list item), and the action’s associated context (for example: the specific item to be removed). To avoid unnecessary verbosity, button names should be as succinct as possible while still being descriptive and unique.
1212

13-
To explore how meaningful names can be set in code, refer to the [Examples](#examples) below.
13+
Refer to [Identifying GitHub comments](#identifying-github-comments) below for an example of a succinct, unique name. To explore how meaningful names can be set in code, refer to the [examples](#examples) below.
1414

1515
### Why is a meaningful name necessary?
1616

1717
Clear and consistent labels set user expectations for button actions, giving users confidence that activating a button will have the outcome they expect.
1818

19-
Screen readers (e.g. VoiceOver) provide overlays to enable users to jump to specific types of elements, including buttons. Elements are listed by their names. When buttons don’t have meaningful names, it’s not possible to determine which action will be performed when selecting them from the list.
19+
Screen readers (for example: VoiceOver) provide overlays to enable users to jump to specific types of elements, including buttons. Elements are listed by their names. When buttons don’t have meaningful names, it’s not possible to determine which action will be performed when selecting them from the list.
2020

2121
## How to test names
2222

@@ -30,37 +30,53 @@ When reviewing buttons on a page, ensure the following are true:
3030

3131
### For designers
3232

33-
- When including an icon-only (i.e. unlabeled) button in a design, recommend an accessible name.
33+
- When including an unlabeled, icon-only button in a design, recommend an accessible name.
3434
- When including multiple buttons that peform the same function in a design, use the same label for each.
3535

3636
### For engineers
3737

38-
- When a button doesn’t have a visible label (e.g. an [IconButton](https://primer.style/view-components/components/iconbutton)), provide an accessible name. Refer to [ARIA 14: Using `aria-label` to provide an invisible label where a visible label cannot be used](https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA14).
39-
- Because `aria-label` doesn’t _supplement_ visible labels but rather _supplants_ them, when a button has a visible label, include that label in its accessible name. A best practice is to have the text of the label at the start of the name.
38+
- When a button doesn’t have a visible label (for example: an [IconButton](https://primer.style/view-components/components/iconbutton)), provide an accessible name. Refer to [ARIA 14: Using `aria-label` to provide an invisible label where a visible label cannot be used](https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA14).
39+
- Because `aria-label` doesn’t _supplement_ visible labels but rather _supplants_ them, when a button has a visible label, include that label in its accessible name. A good practice is to have the text of the label at the start of the name.
4040
- Don’t use `aria-label` when its content would be identical to a button’s visible label.
4141
- Don’t reuse the same (visible) label or (invisible) name for buttons which perform different actions.
4242

4343
## Examples
4444

45-
### 👎 Bad: Redundant `aria-label` attribute
46-
47-
The button below has a redundant and unnecessary `aria-label` attribute:
48-
49-
```HTML
50-
<button type="button" aria-label="OK">OK</button>
51-
```
52-
53-
### 👎 Bad: Missing name
54-
55-
The button below is missing a name:
56-
57-
```HTML
58-
<button type="button"><img src="https://avatars.githubusercontent.com/u/3104489?s=32"></button>
59-
```
60-
61-
### 👎 Bad: Meaningless name, reused for unrelated buttons
62-
63-
Although each button in the example below performs a different action, they all have the same name: ❌ (“cross mark”). This name does not describe the action that occurs when a given button is activated, nor does it describe the action’s context.
45+
<DoDontContainer>
46+
<Do>
47+
<Code className="language-html">
48+
{`<button type="button">OK</button>`}
49+
</Code>
50+
<Caption>The button does not have a redundant `aria-label` attribute.</Caption>
51+
</Do>
52+
<Dont>
53+
<Code className="language-html">
54+
{`<button type="button">OK</button>`}
55+
</Code>
56+
<Caption>The button has a redundant and unnecessary `aria-label` attribute.</Caption>
57+
</Dont>
58+
</DoDontContainer>
59+
60+
61+
<DoDontContainer>
62+
<Do>
63+
<Code className="language-html">
64+
{`<button type="button" aria-label="smockle’s profile"><img alt="smockle" src="https://avatars.githubusercontent.com/u/3104489?s=32"></button>`}
65+
</Code>
66+
<Caption>The button should have an accessible name.</Caption>
67+
</Do>
68+
<Dont>
69+
<Code className="language-html">
70+
{`<button type="button"><img src="https://avatars.githubusercontent.com/u/3104489?s=32"></button>`}
71+
</Code>
72+
<Caption>The button should not be missing a name.</Caption>
73+
</Dont>
74+
</DoDontContainer>
75+
76+
77+
### Meaningful and unique names
78+
79+
Each button in the example below has a unique name which describes its action (“Remove”) and its action’s context (for example: “'Apples'”).
6480

6581
```HTML
6682
<script>
@@ -70,31 +86,13 @@ Although each button in the example below performs a different action, they all
7086
}
7187
</script>
7288
<ul>
73-
<li>Apples <button onclick="removeItem(event)" type="button"></button></li>
74-
<li>Bananas <button onclick="removeItem(event)" type="button"></button></li>
75-
<li>Cantaloupes <button onclick="removeItem(event)" type="button"></button></li>
89+
<li>Apples <button onclick="removeItem(event)" aria-label="Remove 'Apples'" type="button"></button></li>
90+
<li>Bananas <button onclick="removeItem(event)" aria-label="Remove 'Bananas'" type="button"></button></li>
91+
<li>Cantaloupes <button onclick="removeItem(event)" aria-label="Remove 'Cantaloupes'" type="button"></button></li>
7692
</ul>
7793
```
7894
79-
### 👍 Good: No redundant `aria-label` attribute
80-
81-
The button below does not have a redundant `aria-label` attribute:
82-
83-
```HTML
84-
<button type="button">OK</button>
85-
```
86-
87-
### 👍 Good: Name is provided
88-
89-
The button below has an accessible name:
90-
91-
```HTML
92-
<button type="button" aria-label="smockle’s profile"><img alt="smockle" src="https://avatars.githubusercontent.com/u/3104489?s=32"></button>
93-
```
94-
95-
### 👍 Good: Meaningful and unique names
96-
97-
Each button in the example below has a unique name which describes its action (“Remove”) and its action’s context (e.g. “'Apples'”).
95+
Although each button in the example below performs a different action, they all have the same name: ❌ (“cross mark”). This name does not describe the action that occurs when a given button is activated, nor does it describe the action’s context.
9896
9997
```HTML
10098
<script>
@@ -104,12 +102,13 @@ Each button in the example below has a unique name which describes its action (
104102
}
105103
</script>
106104
<ul>
107-
<li>Apples <button onclick="removeItem(event)" aria-label="Remove 'Apples'" type="button"></button></li>
108-
<li>Bananas <button onclick="removeItem(event)" aria-label="Remove 'Bananas'" type="button"></button></li>
109-
<li>Cantaloupes <button onclick="removeItem(event)" aria-label="Remove 'Cantaloupes'" type="button"></button></li>
105+
<li>Apples <button onclick="removeItem(event)" type="button"></button></li>
106+
<li>Bananas <button onclick="removeItem(event)" type="button"></button></li>
107+
<li>Cantaloupes <button onclick="removeItem(event)" type="button"></button></li>
110108
</ul>
111109
```
112110
111+
113112
## Additional resources
114113
115114
### Terminology: “label” vs “name”
@@ -155,7 +154,7 @@ The name may be hidden and only exposed by assistive technology, whereas a label
155154
156155
#### Identifying GitHub comments
157156
158-
When a button is associated with a specific comment, a comment indentifier should be included within the button’s name. [`reaction_target_identifier`](https://github.com/github/github/blob/016b875e0542c0781a3c6f5ed27c58c472cc6717/app/components/reactions/reactions_component.rb#L47-L51) (only accessible to GitHub staff) uses [`aria-label-date`](https://github.com/github/github/blob/9bea7b7d0d120df6b9b864fda39fe374479acc0d/app/components/application_component.rb#L68-L78) (only accessible to GitHub staff) to generates a concise, unique comment identifier.
157+
When a button is associated with a specific comment, a comment indentifier should be included within the button’s name. [`reaction_target_identifier`](https://github.com/github/github/blob/016b875e0542c0781a3c6f5ed27c58c472cc6717/app/components/reactions/reactions_component.rb#L47-L51) (only accessible to GitHub staff) uses [`aria-label-date`](https://github.com/github/github/blob/9bea7b7d0d120df6b9b864fda39fe374479acc0d/app/components/application_component.rb#L68-L78) (only accessible to GitHub staff) to generate a concise, unique comment identifier.
159158
160159
For example, `reaction_target_identifier` could be used in a reply-to-comment button’s name. In all cases, `reaction_target_identifier` adds the comment’s author and timestamp; conditionally, as needed, `reaction_target_identifier` adds progressively-verbose date information:
161160

content/accessibility/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {Grid, Flex, Box, Link, Text, Label} from '@primer/components'
3535
<Box as="p">Events like toasts and status messages are visually communicated to GitHub users. Making sure those announcements are read via assistive technology allows users with low or no vision to get that status information.</Box>
3636
</div>
3737
<div>
38-
<Link href="/design/accessibility/button-purpose" fontWeight="bold">Describing a button’s purpose</Link>
38+
<Link href="/design/accessibility/descriptive-buttons" fontWeight="bold">Descriptive buttons</Link>
3939
<Box as="p">Labeling buttons properly let's users know what will happen when they activate the control, lessens errors, and increases confidence.</Box>
4040
</div>
4141
<div>

src/@primer/gatsby-theme-doctocat/nav.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
url: /accessibility/alternative-text-for-images
2121
- title: Assistive technology announcements
2222
url: /accessibility/announcements
23-
- title: Describing a button’s purpose
24-
url: /accessibility/button-purpose
23+
- title: Descriptive buttons
24+
url: /accessibility/descriptive-buttons
2525
- title: Focus management
2626
url: /accessibility/focus-management
2727
- title: Headings

0 commit comments

Comments
 (0)