MudTable: Add AriaLabel parameter for accessibility#11995
MudTable: Add AriaLabel parameter for accessibility#11995danielchalmers merged 4 commits intoMudBlazor:devfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces an AriaLabel parameter to the MudTable component, enhancing accessibility by allowing developers to specify an aria-label for the underlying HTML table element. This enables screen readers to announce the purpose of the table, improving usability for users with assistive technologies. The changes include adding the new parameter to MudTableBase.cs, binding it in MudTable.razor, adding a unit test, and updating the documentation. I have provided one review comment to address a potential issue.
|
Hi @ScarletKuro Pipeline passed and waiting for approval. Thanks |
|
Would we want |
|
Looks good! A note on the validity of empty strings for aria-label: I had a doubt, since the html specs state that an empty string is different that the absence of the attribute. I feared that it causes unpredictable behaviour, like some assistive technologies shadowing an existing label, and others ignoring the attribute. But the name computation for accessible name is clear on that: an empty string must be ignored : https://w3c.github.io/accname/#computation-steps. |
|
|
Thanks! Agreed — per accname, empty aria-label is ignored. This PR follows the same pattern as MudMenu and others by binding the value directly. I’m happy to either keep it (consistent and spec-compliant) or update to omit the attribute when the value is empty/whitespace using string.IsNullOrWhiteSpace if that’s preferred. Let me know which you’d like; I can also add a brief note in the docs clarifying the empty-string behavior. |
|
@danielchalmers @igotinfected Could you approve this pr? |
There was a problem hiding this comment.
Pull Request Overview
This PR adds accessibility support to MudTable by introducing an AriaLabel parameter that renders as the aria-label attribute on the HTML table element. It also includes a minor documentation correction.
- Added
AriaLabelparameter toMudTableBaseclass - Updated
MudTable.razorto render thearia-labelattribute - Added unit test to verify the
AriaLabelparameter renders correctly - Created documentation example demonstrating accessibility usage
- Fixed a minor text issue in documentation (removed zero-width space character)
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/MudBlazor/Components/Table/MudTableBase.cs | Adds AriaLabel property with XML documentation |
| src/MudBlazor/Components/Table/MudTable.razor | Applies AriaLabel to the table element's aria-label attribute |
| src/MudBlazor.UnitTests/Components/TableTests.cs | Adds test verifying AriaLabel renders correctly on the table element |
| src/MudBlazor.Docs/Pages/Components/Table/TablePage.razor | Adds accessibility section to documentation and fixes text formatting |
| src/MudBlazor.Docs/Pages/Components/Table/Examples/TableAriaLabelExample.razor | Creates example demonstrating AriaLabel usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
I think LGTM! |
|
Thank you! |
Summary
Motivation
Changes
Usage
Notes
Testing
Fixes MudTable - Allow adding aria-label to the <table> element #11929
Checklist