Example of Tabs with Manual Activation
The below example section demonstrates a tabs widget that implements the tabs design pattern. In this example, a new panel is displayed only after the user activates a tab with either Space, Enter, or a mouse click. Typically, manual activation of tabs is only necessary when panels cannot be displayed instantly, i.e., not all the panel content is present in the DOM. For additional guidance, see Deciding When to Make Selection Automatically Follow Focus.
Similar examples include:
- Example of Tabs with Automatic Activation: A tabs widget where tabs are automatically activated and their panel is displayed when they receive focus.
Example
Nils Frahm is a German musician, composer and record producer based in Berlin. He is known for combining classical and electronic music and for an unconventional approach to the piano in which he mixes a grand piano, upright piano, Roland Juno-60, Rhodes piano, drum machine, and Moog Taurus.
Agnes Caroline Thaarup Obel is a Danish singer/songwriter. Her first album, Philharmonics, was released by PIAS Recordings on 4 October 2010 in Europe. Philharmonics was certified gold in June 2011 by the Belgian Entertainment Association (BEA) for sales of 10,000 Copies.
Fear of complicated buildings:
A complex complex complex.
Accessibility Features
To demonstrate the effects of deleting a tab, the third tab, labeled Joke
,
can be deleted when it has focus by pressing Delete.
Keyboard Support
Key | Function |
---|---|
Tab |
|
Enter Space |
When a tab has focus, activates the tab, causing its associated panel to be displayed. |
Right Arrow |
When a tab has focus:
|
Left Arrow |
When a tab has focus:
|
Home | When a tab has focus, moves focus to the first tab. |
End | When a tab has focus, moves focus to the last tab. |
Delete | When focus is on the Joketab, removes the tab from the tab list and places focus on the previous tab. |
Role, Property, State, and Tabindex Attributes
Role | Attribute | Element | Usage |
---|---|---|---|
tablist
|
div
|
Indicates that the element serves as a container for a set of tabs. | |
aria-label=
|
div
|
Provides a label that describes the purpose of the set of tabs. | |
tab
|
button
|
|
|
aria-selected=
|
button
|
|
|
aria-selected=
|
button
|
|
|
tabindex=
|
button
|
|
|
aria-controls=
|
button
|
Refers to the tabpanel element associated with the tab.
|
|
tabpanel
|
div
|
|
|
aria-labelledby=
|
div
|
|
|
tabindex=
|
div
|
|
Javascript and CSS Source Code
HTML Source Code