third_party/aria-practices/src/content/patterns/tabs/tabs-pattern.html
Tabs are a set of layered sections of content, known as tab panels, that display one panel of content at a time. Each tab panel has an associated tab element, that when activated, displays the panel. The list of tab elements is arranged along one edge of the currently displayed panel, most commonly the top edge.
Terms used to describe this design pattern include:
Tabs or Tabbed InterfaceA set of tab elements and their associated tab panels.Tab ListA set of tab elements contained in a tablist element.tabAn element in the tab list that serves as a label for one of the tab panels and can be activated to display that panel.tabpanelThe element that contains the content associated with a tab.
When a tabbed interface is initialized, one tab panel is displayed and its associated tab is styled to indicate that it is active. When the user activates one of the other tab elements, the previously displayed tab panel is hidden, the tab panel associated with the activated tab becomes visible, and the tab is considered "active".
For the tab list:
Tab:
tab element.When focus is on a tab element in a horizontal tab list:
When focus is on a tab in a tablist with either horizontal or vertical orientation:
It is recommended that tabs activate automatically when they receive focus as long as their associated tab panels are displayed without noticeable latency. This typically requires tab panel content to be preloaded. Otherwise, automatic activation slows focus movement, which significantly hampers users' ability to navigate efficiently across the tab list. For additional guidance, see Deciding When to Make Selection Automatically Follow Focus.
When a tab list has its aria-orientation set to vertical:
Down Arrow performs as Right Arrow is described above.
Up Arrow performs as Left Arrow is described above.
If the tab list is horizontal, it does not listen for Down Arrow or Up Arrow so those keys can provide their normal browser scrolling functions even when focus is inside the tab list.
When the tabpanel does not contain any focusable elements or the first element with content is not focusable, the tabpanel should set tabindex="0" to include it in the tab sequence of the page.
tablist.tab has role tabpanel.tablist has aria-labelledby set to a value that refers to the labelling element. Otherwise, the tablist element has a label provided by aria-label.tab has the property aria-controls referring to its associated tabpanel element.tab element has the state aria-selected set to true and all other tab elements have it set to false.tabpanel has the property aria-labelledby referring to its associated tab element.tab element has a popup menu, it has the property aria-haspopup set to either menu or true.tablist element is vertically oriented, it has the property aria-orientation set to vertical. The default value of aria-orientation for a tablist element is horizontal.