Definition
Tabs or Tabbed Interfaces are groupings of content that display one specific piece of content at a time, called a Tab panel. A user interacts with a list of Tab elements—also known as a Tab list—which can be displayed on any side of the Tab panel. For better user interactions, Tab lists are typically located on the top Tab panel.
Here are a few Tab terms to remember:
- Tab List
- An element that wraps a list of Tab elements
- Tab
- Elements that are contained within the Tab list itself. These are the descriptive element a user will interact with
- When a specific Tab element is activated, the corresponding Tab panel content will be displayed
- The focus area will default to the first Tab element in the Tab list order
- Tab Panel
- An element that displays the primary content for the activated Tab element
- Activated Tab
- An element has unique style indicators to notify the user which Tab and corresponding Tab panel content is currently being viewed and is active
Focus Expectations
- Tabbable Elements have visible focus states
- Standard practice dictates that when the focus state leaves the currently activated Tab element it should not move directly to the next Tab element in the Tab List order, but it should move to its corresponding Tab panel
- A great example of this can be found here Danish Composers
- Tab panels allow for proper progression of focus states depending on the nested content
- When the current focus state is on a Tab panel and there is no focusable content within that element and the focus state should move to the next focusable element on the page
Semantic Elements
Tab List
<ul>
or<ol>
<nav>
<menu>
<div>
(should be used only when no other semantic element is available)
Tab Element
- if Tab List is
<ul>
or<ol>
the Tab element must be<li>
- If Tab List is
<nav>
the Tab element must be<a>
,<div>
- If Tab List is
<menu>
the Tab elements could be<li>
,<script>
, or<template>
- If the Tab list is a
<div>
, the Tab element is most flexible and ensures that the Tab elements nested within the<div>
are semantic and have the appropriate roles and Aria attributes-attributes
- if Tab List is
Tab Panel
<article>
<section>
<div>
(should be used only when no other semantic element is available)
ARIA Roles and Attributes
Tab List
- The role
tablist
is applied to the element containing the Tab elements - When providing a role of
tablist
to the element, there MUST be a direct child/children with the role ‘tab` - If the Tab list element has a visual
<label>
or<heading>
element,aria-labeledby
must also be applied to the Tab list element with a value that accurately represents the<label>
or<heading>
element
- The role
Tab Element
- The role
tab
is applied to Tab elements which will be a direct child/children of the element containing the roletablist
- Tab elements have the role of
aria-controls
with a value that is pointed at theid
of its corresponding Tab panel (check additional resources –aria-controls) - Tab elements have an
aria-selected
role, and the currently activated Tab element should have the value oftrue
otherwise a value offalse
- The role
If a popup menu is associated with a Tab element, ensure it has the property
aria-haspopup
set to eithermenu
ortrue
(check additional resources –aria-haspopup)Tab Panel
- The Tab panel element should have an
aria-labeledby
role with the value of the Tab elementid
associated with it - The Tab panel should have a default value of
tabindex="0"
to include it in the tab sequence of the page unless there are other focusable elements nested in the content or the first element with content is focusable
- The Tab panel element should have an
Keyboard Interactions
- Tab: moves focus to the next focusable element
- Shift + Tab: moves focus to the previous focusable element
- Enter or Space: activates the first tab in Tab list if it was not activated automatically on focus
- Shift + F10: opens any associated popup menus
- Home (optional): moves focus to the first Tab element
- End (optional): moves focus to the last Tab element
- Delete (optional): if the Delete option is available to users
- When pressed, the current activated Tab element and its associated Tab panel will close setting the focus on the next Tab element
- If Delete is pressed on the last Tab element in the Tab list order, the focus state should revert to the previous (second to last) Tab element unless otherwise specified (below) by default
- If otherwise specified, the users expect that the focus state will move to the next reasonable and focusable element on the page
As an alternative to Delete, or in addition to supporting Delete, the delete function should be available in a context menu