Skip to content

Commit 4d0dcc4

Browse files
DBowen33andrewseguin
authored andcommitted
fix(material/list): update documentation (#30883)
update list a11y documentation fixes b/247892626 (cherry picked from commit 204b289)
1 parent e584766 commit 4d0dcc4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/material/list/list.md

+29
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,35 @@ anchors, including buttons and checkboxes.
241241
Always provide an accessible label for the `<mat-nav-list>` element via `aria-label` or
242242
`aria-labelledby`.
243243

244+
To provide the best screen reader experience for a list, wrap each anchor element with a `<li>` or `<div role="listitem">` element and wrap all of the anchor elements with a `<ul>` element or `<div role="list">` element.
245+
246+
```html
247+
<mat-nav-list aria-label="Select a folder">
248+
<ul>
249+
@for (link of list; track link) {
250+
<li>
251+
<a mat-list-item href="..." [activated]="link.isActive">{{ link }}</a>
252+
</li>
253+
}
254+
</ul>
255+
</mat-nav-list>
256+
```
257+
258+
#### Action
259+
260+
To provide the best screen reader experience for a list, wrap each button element with a `<li>` or `<div role="listitem">` element and add `role="list"` to `<mat-action-list>`.
261+
262+
```html
263+
<mat-action-list role="list" aria-label="Post actions">
264+
<li>
265+
<button mat-list-item (click)="save()">Save</button>
266+
</li>
267+
<li>
268+
<button mat-list-item (click)="undo()">Undo</button>
269+
</li>
270+
</mat-action-list>
271+
```
272+
244273
#### Selection
245274

246275
You should use `MatSelectionList` and `MatListOption` for lists that allow the user to select one

0 commit comments

Comments
 (0)