UI Patterns

TabsStatusrelease

Automatically activated tabs display their panel when they receive focus.

Guidance

Automatic activation should be used when the tabpanel content is immediately available and present in the DOM. Manual activation (requiring a click or enter/space keydown event) should be used if the content is not immediately present, for example if it requires a network request to retrieve it. Automatic activation can be enabled by setting activation: true when initialising the tabs.

Example

Open in a new tab

Dependencies and installation

PackageInstallation
@stormid/tabs
npm i -S @stormid/tabs

Code

<div class="tabs js-tabs"><div class="tabs__tabslist" role="tablist"><a id="tab-1" class="tabs__tab js-tabs__link" href="#panel-1" role="tab">Tab 1</a><a id="tab-2" class="tabs__tab js-tabs__link" href="#panel-2" role="tab">Tab 2</a><a id="tab-3" class="tabs__tab js-tabs__link" href="#panel-3" role="tab">Tab 3</a></div><div id="panel-1" class="tabs__tabpanel" role="tabpanel">Panel 1</div><div id="panel-2" class="tabs__tabpanel" role="tabpanel" hidden><p>Panel 2</p><p><a href="/">Test link</a></p><p><a href="/">Test link</a></p></div><div id="panel-3" class="tabs__tabpanel" role="tabpanel" hidden><p>Panel 3</p><p><a href="/">Test link</a></p><p><a href="/">Test link</a></p></div></div>
import tabs from '@stormid/tabs';

tabs('.js-tabs');

Acceptance criteria

The following is a list of example acceptance criteria to test against when using this pattern. These critera should test that the specific markup requirements are met, and that the tabs behave visually and functionally as expected.

For validation in developer tools / web inspector

For visual validation

For functional validation

References