Dostępność
a11y/tabs-selected
Every role="tab" carries aria-selected, true on the active tab and false on the others.
poważnastatyczneWCAG 4.1.2 · Afe-a11y-tabs-accordion
Dlaczego
Sighted users see which tab is active from its style. A screen reader user hears "tab, 2 of 4" and nothing else unless aria-selected says which one is shown.
Poprawka
Bind aria-selected to the same state that styles the active tab: true on it, false on the rest. Give the active tab tabindex="0" and the others tabindex="-1", and connect each tab to its panel with aria-controls and the panel back with aria-labelledby.
Przykłady
<!-- bad -->
<button role="tab" class="active">Monthly</button>
<!-- good -->
<button role="tab" aria-selected="true" aria-controls="p-monthly" id="t-monthly">Monthly</button>Źródła
Fakty
- Identyfikator
a11y/tabs-selected- Waga
- poważna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
htmlangularvuesvelteastrojsx- WCAG 2.2
- 4.1.2, poziom A
- Uczy jej skill
fe-a11y-tabs-accordionTabs and accordions- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain a11y/tabs-selected