Detailed overview of the accessibility features implemented in CoreUI Vue Tabs, ensuring compliance with WAI-ARIA guidelines.
Accessibility
Dynamic tabbed interfaces, as described in the WAI ARIA Authoring Practices, require role="tablist", role="tab", role="tabpanel", and additional aria- attributes in order to convey their structure, functionality and current state to users of assistive technologies (such as screen readers).
WAI-ARIA Roles
- The element that serves as the container for the set of tabs has the role
tablist. - Each element that serves as a tab has the role
taband is contained within the element with the roletablist. - Each element that contains the content panel for a tab has the role
tabpanel. - If the tab list has a visible label, the element with the role
tablisthasaria-labelledbyset to a value that refers to the labeling element. Otherwise, thetablistelement has a label provided byaria-label. - Each element with the role
tabhas the propertyaria-controlsreferring to its associatedtabpanelelement. - The active tab element has the state
aria-selectedset totrue, and all other tab elements have it set tofalse. - Each element with the role
tabpanelhas the propertyaria-labelledbyreferring to its associatedtabelement.
Our Vue Tabs component automatically manages all role="..." and aria- attributes for accessibility. It also handles the selected state by adding aria-selected="true" to the active tab. Additionally, you have the flexibility to manually set these attributes, as shown in the example below:
<CTabs :activeItemKey="2">
<CTabList variant="tabs">
<CTab id="home-tab" aria-controls="home-tab-pane" :itemKey="1">Home</CTab>
<CTab id="profile-tab" aria-controls="profile-tab-pane" :itemKey="2">Profile</CTab>
<CTab id="contact-tab" aria-controls="contact-tab-pane" :itemKey="3">Contact</CTab>
<CTab id="disabled-tab" aria-controls="disabled-tab-pane" disabled :itemKey="4">Disabled</CTab>
</CTabList>
<CTabContent>
<CTabPanel id="home-tab-pane" class="p-3" aria-labelledby="home-tab-pane" aria-labelledby="home-tab" :itemKey="1">
Home tab content
</CTabPanel>
<CTabPanel id="profile-tab-pane" class="p-3" aria-labelledby="profile-tab-pane" aria-labelledby="profile-tab" :itemKey="2">
Profile tab content
</CTabPanel>
<CTabPanel id="contact-tab-pane" class="p-3" aria-labelledby="contact-tab-pane" aria-labelledby="contact-tab" :itemKey="3">
Contact tab content
</CTabPanel>
<CTabPanel id="disabled-tab-pane" class="p-3" aria-labelledby="disabled-tab-pane" aria-labelledby="disabled-tab" :itemKey="4">
Disabled tab content
</CTabPanel>
</CTabContent>
</CTabs>This example demonstrates how to manually set aria-selected, aria-controls, and aria-labelledby attributes on your <CTab>’s and <CTabPanels>’s.
Keyboard Interaction
When focus enters the tab list:
Tab: It places focus on the active tab element.
When focus is on a tab element:
Tab: Moves focus to the next element in the tab sequence, typically the tabpanel unless the first focusable element inside the tabpanel is found earlier.
Left Arrow: Moves focus to the previous tab. If on the first tab, it wraps around to the last tab.
Right Arrow: Moves focus to the next tab. If on the last tab, it wraps around to the first tab.
Home: Moves focus to the first tab.
End: Moves focus to the last tab.