Example of Tabs with Automatic Activation
This example section demonstrates a tabs widget that implements the design pattern for tabs. In this example, a tab is automatically activated and its associated panel is displayed when the tab receives focus. Tabs should only be automatically activated in circumstances where panels can be displayed instantly, i.e., all 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 Manual Activation: A tabs widget where users activate a tab and display its panel by pressing Space or Enter.
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 |
|
Right Arrow |
|
Left Arrow |
|
Home | Moves focus to the first tab and activates it. |
End | Moves focus to the last tab and activates it. |
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