Skip to content

fix(material/list): update A11y documentation #30883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/material/list/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,35 @@ anchors, including buttons and checkboxes.
Always provide an accessible label for the `<mat-nav-list>` element via `aria-label` or
`aria-labelledby`.

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.

```html
<mat-nav-list aria-label="Select a folder">
<ul>
@for (link of list; track link) {
<li>
<a mat-list-item href="..." [activated]="link.isActive">{{ link }}</a>
</li>
}
</ul>
</mat-nav-list>
```

#### Action

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>`.

```html
<mat-action-list role="list" aria-label="Post actions">
<li>
<button mat-list-item (click)="save()">Save</button>
</li>
<li>
<button mat-list-item (click)="undo()">Undo</button>
</li>
</mat-action-list>
```

#### Selection

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