Skip to content

Commit a54fbd0

Browse files
zelliottcopybara-github
authored andcommitted
docs(button,iconbutton): add docs for soft-disabled attribute
Fixes #5672 PiperOrigin-RevId: 651409230
1 parent 281c092 commit a54fbd0

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

docs/components/button.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,28 @@ attribute to buttons whose labels need a more descriptive label.
236236
<md-elevated-button aria-label="Add a new contact">Add</md-elevated-button>
237237
```
238238

239+
### Focusable and disabled
240+
241+
By default, disabled buttons are not focusable with the keyboard, while
242+
"soft-disabled" buttons are. Some use cases encourage focusability of disabled
243+
toolbar items to increase their discoverability.
244+
245+
See the
246+
[ARIA guidelines on focusability of disabled controls](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls)<!-- {.external} -->
247+
for guidance on when this is recommended.
248+
249+
```html
250+
<div role="toolbar">
251+
<md-text-button>Copy</md-text-button>
252+
<md-text-button>Cut</md-text-button>
253+
<!--
254+
This button is disabled but kept focusable to improve its discoverability
255+
in the toolbar.
256+
-->
257+
<md-text-button soft-disabled>Paste</md-text-button>
258+
</div>
259+
```
260+
239261
## Elevated button
240262

241263
<!-- go/md-elevated-button -->
@@ -703,7 +725,6 @@ Token | Default value
703725

704726
## API
705727

706-
707728
### MdElevatedButton <code>&lt;md-elevated-button&gt;</code>
708729

709730
#### Properties
@@ -713,6 +734,7 @@ Token | Default value
713734
| Property | Attribute | Type | Default | Description |
714735
| --- | --- | --- | --- | --- |
715736
| `disabled` | `disabled` | `boolean` | `false` | Whether or not the button is disabled. |
737+
| `softDisabled` | `soft-disabled` | `boolean` | `false` | Whether the button is "soft-disabled" (disabled but still focusable). |
716738
| `href` | `href` | `string` | `''` | The URL that the link button points to. |
717739
| `target` | `target` | `string` | `''` | Where to display the linked `href` URL for a link button. Common options include `_blank` to open in a new tab. |
718740
| `trailingIcon` | `trailing-icon` | `boolean` | `false` | Whether to render the icon at the inline end of the label rather than the inline start.<br>_Note:_ Link buttons cannot have trailing icons. |

docs/components/icon-button.md

+31-3
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,34 @@ more descriptive label when selected.
196196
</md-icon-button>
197197
```
198198

199+
### Focusable and disabled
200+
201+
By default, disabled icon buttons are not focusable with the keyboard, while
202+
"soft-disabled" icon buttons are. Some use cases encourage focusability of
203+
disabled toolbar items to increase their discoverability.
204+
205+
See the
206+
[ARIA guidelines on focusability of disabled controls](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls)<!-- {.external} -->
207+
for guidance on when this is recommended.
208+
209+
```html
210+
<div role="toolbar">
211+
<md-icon-button aria-label="Copy">
212+
<md-icon>copy</md-icon>
213+
</md-icon-button>
214+
<md-icon-button aria-label="Cut">
215+
<md-icon>cut</md-icon>
216+
</md-icon-button>
217+
<!--
218+
This icon button is disabled but kept focusable to improve its
219+
discoverability in the toolbar.
220+
-->
221+
<md-icon-button aria-label="Paste" soft-disabled>
222+
<md-icon>paste</md-icon>
223+
</md-icon-button>
224+
</div>
225+
```
226+
199227
## Icon Button
200228

201229
Standard icon buttons do not have a background or outline, and have the lowest
@@ -319,7 +347,7 @@ Token | Default value
319347
### Filled Icon Button tokens
320348

321349
Token | Default value
322-
-------------------------------------------------- | ------------------------
350+
-------------------------------------------------- | -------------
323351
`--md-filled-icon-button-selected-container-color` | `--md-sys-color-primary`
324352
`--md-filled-icon-button-container-shape` | `--md-sys-shape-corner-full`
325353
`--md-filled-icon-button-container-width` | `40px`
@@ -391,7 +419,7 @@ Token | Default value
391419
### Outlined Icon Button tokens
392420

393421
Token | Default value
394-
-------------------------------------------- | ------------------------
422+
-------------------------------------------- | ----------------------------
395423
`--md-outlined-icon-button-outline-color` | `--md-sys-color-outline`
396424
`--md-outlined-icon-button-outline-width` | `1px`
397425
`--md-outlined-icon-button-container-shape` | `--md-sys-shape-corner-full`
@@ -428,7 +456,6 @@ Token | Default value
428456

429457
## API
430458

431-
432459
### MdIconButton <code>&lt;md-icon-button&gt;</code>
433460

434461
#### Properties
@@ -472,6 +499,7 @@ Token | Default value
472499
| Property | Attribute | Type | Default | Description |
473500
| --- | --- | --- | --- | --- |
474501
| `disabled` | `disabled` | `boolean` | `false` | Disables the icon button and makes it non-interactive. |
502+
| `softDisabled` | `soft-disabled` | `boolean` | `false` | "Soft-disables" the icon button (disabled but still focusable). |
475503
| `flipIconInRtl` | `flip-icon-in-rtl` | `boolean` | `false` | Flips the icon if it is in an RTL context at startup. |
476504
| `href` | `href` | `string` | `''` | Sets the underlying `HTMLAnchorElement`'s `href` resource attribute. |
477505
| `target` | `target` | `string` | `''` | Sets the underlying `HTMLAnchorElement`'s `target` attribute. |

0 commit comments

Comments
 (0)