Closed
Description
Comparing the current implementation of Tabs to the one described on this MDN page, there are a couple of issues related to accessibility.
Things we are missing are:
- Elements with the role
tab
must either be a child of an element with thetablist
role, or have theirid
part of thearia-owns
property of atablist
. - They should contain the
aria-controls
property identifying an element with thetabpanel
role. - When working with elements with the
tab
role, when they are selected or active, they should have theiraria-selected
attribute set totrue
, otherwise it should be set tofalse
. - When a
tab
is selected or active, its controlledtabpanel
should have itsaria-expanded
attribute set totrue
and itshidden
attribute set tofalse
, otherwise the reverse. - It is recommended to use a
button
element with the roletab
for their built-in functional and accessible features instead, as opposed to needing to add them yourself. For controlling tab key functionality for elements with the roletab
, it is recommended to set all non-active elements totabindex=-1
, and to set the active element totabindex=0
.
Also, I would highlight this sentence on the same MDN page:
While there are ways to build tab-like functionality without JavaScript, there are no substitute combination of HTML and CSS only that will provide the same set of functionality that's required above for accessible tabs with content.
We should decide how to approach this.
I was thinking to provide a separate package containing JS file for each component which provides accessibility improvements.