Related views. One context.
Switch between peer panels without losing the surrounding task.
Interactive example
Design for the task.
Use tabs for closely related views. Keep the selected state easy to identify.
Enhance native buttons.
Load components.js to enable selection and keyboard navigation.
Predictable keyboard behaviour.
Use Left and Right arrows to switch tabs. Home and End select the first and last tabs.
Arrow keys, Home and End select and focus tabs. Tab moves from the active tab into its panel.
Code
<div data-tabs><div class="sk-tabs" role="tablist" aria-label="Resource view"><button id="usage-tab" role="tab" aria-selected="true" aria-controls="usage-panel" type="button">Usage</button><button id="code-tab" role="tab" aria-selected="false" aria-controls="code-panel" tabindex="-1" type="button">Implementation</button><button id="access-tab" role="tab" aria-selected="false" aria-controls="access-panel" tabindex="-1" type="button">Accessibility</button></div><div class="sk-panel" id="usage-panel" role="tabpanel" aria-labelledby="usage-tab" tabindex="0"><h3>Design for the task.</h3><p>Use tabs for closely related views. Keep the selected state easy to identify.</p></div><div class="sk-panel" id="code-panel" role="tabpanel" aria-labelledby="code-tab" tabindex="0" hidden><h3>Enhance native buttons.</h3><p>Load components.js to enable selection and keyboard navigation.</p></div><div class="sk-panel" id="access-panel" role="tabpanel" aria-labelledby="access-tab" tabindex="0" hidden><h3>Predictable keyboard behaviour.</h3><p>Use Left and Right arrows to switch tabs. Home and End select the first and last tabs.</p></div></div>Usage
- Use tabs for peer views; use links for separate destinations.
- Keep labels short and avoid a large number of tabs.
- Show one panel at a time and preserve each panel’s state.
- Give every instance unique tab and panel IDs.

