Best practice for tables is to provide a caption or aria label for user context when using a screenreader. Screen readers read the caption or name of the table when user navigate to the table, giving users a sense of what the table is about. The caption element is the most straightforward way to give a name to a table, but it is also possible to use aria-label or aria-labelled by.
https://www.w3.org/WAI/tutorials/tables/caption-summary/
https://dequeuniversity.com/checklists/web/tables
In this case, to avoid having to impose a specific style on developers using an MUI table, a useful option would be to provide an optional ariaLabelledBy prop that is applied to the inner <table> tag, such that developers can show or hide a caption visually as necessary.
Developers should be able to specify a caption for implementations of MUI <Table>.
MUI Table: https://material-ui.com/components/tables/
Example using aria-describedBy
https://www.w3.org/WAI/tutorials/tables/caption-summary/#using-aria-describedby-to-provide-a-table-summary
This can be particularly important in cases where multiple tables are in use on a screen. On a page with multiple tables, screen reader users can pull up a list of all tables on the web page, which will show the captions along with the table size.
Good point. Though this is already possible. I guess we should include this by default in our docs
<Table aria-label="a labelled table">....</Table>
<Table><caption>A captioned table</caption></Table>
Nice one! Thank you
@eps1lon Can I update the docs for table with aria-label if that's okay.
@eps1lon Can I update the docs for table with
aria-labelif that's okay.
That'd be nice. Bonus if you add a fully accessible example using a styled description either using caption or aria-describedby.
Most helpful comment
That'd be nice. Bonus if you add a fully accessible example using a styled description either using
captionoraria-describedby.