You need to know two things to build or Tabbed components.
- Roles for a Tabbed component
aria-selected
Roles for a Tabbed component
There are three roles for a Tabbed component:
- Tab
- Tablist
- Tabpanel
A tab role tells screen reader users theyβre on a tab. Tabs should be placed in an element with a tablist role.
<div role="tabslist"> <button role="tab">...</button> <button role="tab">...</button> <button role="tab">...</button></div>When a tab is selected, their respective content must be shown. The content must have a tabpanel role.
Aria-selected
aria-selected indicates whether an element is selected. It can either be true or false.
true: Element is selectedfalse: Element is not selected
aria-selected can only be used in these four roles:
rowgridcelloptiontab
This means aria-selected can only be used in these three composite roles:
gridlistboxtablist
Welcome! Unfortunately, you donβt have access to this lesson. To get access, please purchase the course or enroll in Magical Dev School.
Unlock this lesson