Responsive disclosure navigation
NavigationA navigation bar that folds neatly into a keyboard-friendly disclosure on small screens.
HTML + CSS + JavaScript
aria-expanded="false" Navigation · Complete runnable example
Preloaded panels with one tab stop and predictable arrow-key navigation.
This preview runs in an isolated document. Clipboard writes and saved preferences may be blocked, and printing requires the standalone file. A dialog affects only the example. Reset reloads the original example state.
Use tabs to switch between closely related panels when showing one at a time helps the reader. This example keeps all panel content local and ready, so moving focus can immediately reveal its panel.
The preview, copied text, and downloaded file use this same document.
<!doctype html>
<!--
MIT License
Copyright (c) 2026 MRHTML
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data:; connect-src 'none'; form-action 'none'; object-src 'none'; base-uri 'none'"
/>
<title>MRHTML Workshop | Accessible tabs</title>
<style>
:root {
color-scheme: light;
--ink: #172334;
--muted: #536276;
--blue: #164bbb;
--pale: #e8effe;
--paper: #f7f6f1;
--line: #d8dee7;
--header-clearance: 110px;
font-family: Arial, Helvetica, sans-serif;
}
* {
box-sizing: border-box;
}
html {
scroll-padding-top: var(--header-clearance);
}
body {
margin: 0;
background: var(--paper);
color: var(--ink);
font-size: 16px;
line-height: 1.6;
}
button {
font: inherit;
}
a {
color: var(--blue);
text-underline-offset: 4px;
}
h1,
h2,
h3,
p {
margin: 0;
}
h1,
h2,
h3 {
line-height: 1.12;
letter-spacing: -0.045em;
}
h1 {
font-size: clamp(37px, 6vw, 66px);
}
h2 {
font-size: clamp(27px, 4vw, 39px);
}
h3 {
font-size: 20px;
}
button,
a,
summary {
-webkit-tap-highlight-color: transparent;
}
:focus-visible {
outline: 3px solid var(--blue);
outline-offset: 5px;
}
[hidden] {
display: none !important;
}
::selection {
color: #fff;
background: var(--blue);
}
.wrap {
width: min(1040px, 100%);
margin-inline: auto;
padding-inline: clamp(22px, 5vw, 60px);
}
.eyebrow {
color: var(--blue);
font-size: 11px;
letter-spacing: 0.12em;
font-weight: 700;
text-transform: uppercase;
}
.muted {
color: var(--muted);
}
.button {
display: inline-flex;
align-items: center;
justify-content: space-between;
gap: 25px;
min-height: 46px;
padding: 11px 18px;
border: 1px solid var(--blue);
border-radius: 7px;
background: var(--blue);
color: white;
text-decoration: none;
font-size: 13px;
font-weight: 700;
transition:
background 0.18s,
transform 0.18s;
}
.button:hover {
background: #10398e;
transform: translateY(-2px);
}
.button span {
font-size: 19px;
line-height: 1;
}
.brand {
display: inline-flex;
gap: 10px;
align-items: center;
text-decoration: none;
color: var(--ink);
font-size: 18px;
font-weight: 800;
letter-spacing: -0.7px;
}
.brand-mark {
display: grid;
place-items: center;
background: var(--blue);
color: white;
border-radius: 8px;
width: 32px;
height: 32px;
font-size: 17px;
letter-spacing: -2px;
padding-right: 2px;
}
.skip-link {
position: fixed;
top: 12px;
left: 12px;
z-index: 100;
background: var(--blue);
color: white;
padding: 12px 18px;
border: 2px solid white;
border-radius: 7px;
box-shadow: 0 4px 20px #17233430;
transform: translateY(-160%);
font-weight: 700;
font-size: 14px;
}
.skip-link:focus {
transform: translateY(0);
}
.footer {
font-size: 11px;
color: var(--muted);
display: flex;
justify-content: space-between;
gap: 15px;
padding-block: 24px;
border-top: 1px solid var(--line);
}
main:focus-visible,
section[tabindex='-1']:focus-visible {
outline: 3px solid var(--blue);
outline-offset: -3px;
border-radius: 8px;
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation: none !important;
transition: none !important;
scroll-behavior: auto !important;
}
}
.page-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 25px;
padding-block: 30px;
}
.header-note {
font-size: 11px;
color: var(--muted);
}
main {
padding-block: 26px 55px;
}
.intro {
max-width: 680px;
margin-bottom: 35px;
}
.intro h1 {
margin-top: 14px;
}
.intro h1 span {
color: var(--blue);
}
.intro > p:last-child {
margin-top: 18px;
max-width: 540px;
color: var(--muted);
font-size: 15px;
}
.workspace {
background: #fff;
border: 1px solid var(--line);
border-radius: 16px;
overflow: hidden;
box-shadow: 0 16px 45px #22365108;
}
.tab-list {
padding: 14px 20px 0;
display: flex;
gap: 7px;
background: #f0f3fa;
border-bottom: 1px solid var(--line);
}
.tab {
position: relative;
display: flex;
align-items: center;
gap: 10px;
min-height: 52px;
padding: 12px 22px;
color: var(--muted);
border: 1px solid transparent;
border-bottom: 0;
border-radius: 9px 9px 0 0;
background: transparent;
font-size: 14px;
font-weight: 700;
cursor: pointer;
}
.tab > span {
display: grid;
place-items: center;
width: 21px;
height: 21px;
border: 1px solid currentColor;
border-radius: 50%;
font-size: 10px;
}
.tab[aria-selected='true'] {
color: var(--blue);
background: #fff;
border-color: var(--line);
}
.tab[aria-selected='true']::after {
content: '';
height: 3px;
background: var(--blue);
position: absolute;
bottom: 0;
left: 20px;
right: 20px;
border-radius: 2px;
}
.tab:hover {
color: var(--blue);
}
.tab:focus-visible {
outline-offset: -5px;
}
.panel {
padding: 36px;
display: grid;
grid-template-columns: 1.3fr 1fr;
gap: 32px;
align-items: center;
min-height: 375px;
}
.panel + .panel {
border-top: 1px solid var(--line);
}
.panel h2 {
font-size: 36px;
margin-top: 12px;
}
.panel .description {
margin-top: 17px;
font-size: 14px;
color: var(--muted);
max-width: 380px;
}
.checklist {
list-style: none;
padding: 0;
margin: 24px 0 0;
display: grid;
gap: 12px;
}
.checklist li {
position: relative;
padding-left: 25px;
font-size: 13px;
}
.checklist li::before {
content: '✓';
position: absolute;
left: 0;
top: 0;
color: var(--blue);
font-weight: 700;
}
.panel-art {
min-height: 260px;
align-self: stretch;
border-radius: 12px;
position: relative;
display: grid;
place-items: center;
background: var(--pale);
overflow: hidden;
}
.art-caption {
position: absolute;
bottom: 18px;
left: 20px;
right: 20px;
text-align: center;
color: #344a72;
font-size: 10px;
letter-spacing: 0.03em;
}
.sketch-card {
position: absolute;
background: white;
border: 1px solid #b2c3e6;
border-radius: 8px;
box-shadow: 5px 8px 0 #b4c8f133;
width: 65%;
height: 51%;
top: 21%;
left: 18%;
transform: rotate(-7deg);
padding: 19px;
}
.sketch-card::before {
content: '';
position: absolute;
z-index: -1;
inset: -13px 15px 15px -12px;
background: #fbdb9d;
border-radius: 7px;
border: 1px solid #d4ac64;
transform: rotate(14deg);
}
.sketch-dot {
width: 24px;
height: 24px;
background: var(--blue);
border-radius: 50%;
display: block;
}
.sketch-line {
height: 6px;
background: #d3ddf0;
display: block;
margin-top: 15px;
border-radius: 3px;
width: 80%;
}
.sketch-line:last-child {
width: 55%;
margin-top: 8px;
}
.build-art {
background: #e6eee8;
}
.browser-card {
width: 80%;
background: #fff;
border: 1px solid #a8bfb1;
border-radius: 8px;
box-shadow: 8px 12px 0 #aac0b233;
padding: 13px;
}
.browser-top {
display: flex;
gap: 4px;
border-bottom: 1px solid #dbe3dd;
padding-bottom: 10px;
}
.browser-top i {
width: 5px;
height: 5px;
border: 1px solid #678874;
border-radius: 50%;
}
.browser-layout {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
margin-top: 12px;
}
.browser-layout i {
height: 42px;
background: #e4ece7;
border-radius: 4px;
}
.browser-layout i:first-child {
grid-column: 1/-1;
background: #477c5c;
height: 58px;
}
.refine-art {
background: #fbefd9;
}
.target {
position: relative;
width: 150px;
height: 150px;
border: 1px solid #c4a775;
border-radius: 50%;
display: grid;
place-items: center;
}
.target::before,
.target::after {
content: '';
position: absolute;
border: 1px solid #c4a775;
border-radius: 50%;
inset: 19px;
}
.target::after {
inset: 39px;
}
.target span {
width: 30px;
height: 30px;
border-radius: 50%;
background: var(--blue);
box-shadow: 0 0 0 8px white;
z-index: 1;
}
.panel-notes {
grid-column: 1/-1;
border-top: 1px solid var(--line);
padding-top: 15px;
margin-top: 0;
}
.panel-notes summary {
min-height: 40px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
list-style: none;
cursor: pointer;
color: var(--blue);
font-size: 13px;
font-weight: 700;
}
.panel-notes summary::-webkit-details-marker {
display: none;
}
.panel-notes summary > span {
font-size: 22px;
}
.panel-notes[open] summary > span {
transform: rotate(45deg);
}
.panel-notes p {
font-size: 13px;
color: var(--muted);
max-width: 660px;
margin-top: 10px;
}
.keyboard-hint {
margin-top: 18px;
font-size: 12px;
color: var(--muted);
}
kbd {
font:
11px Arial,
Helvetica,
sans-serif;
border: 1px solid #bac5d4;
border-radius: 4px;
padding: 2px 5px;
background: #fff;
color: var(--ink);
}
@media (max-width: 640px) {
.header-note {
display: none;
}
.page-header {
padding-block: 25px;
}
main {
padding-top: 18px;
}
.intro {
margin-bottom: 26px;
}
.tab-list {
padding: 10px 10px 0;
gap: 3px;
}
.tab {
flex: 1;
justify-content: center;
gap: 7px;
padding: 11px 9px;
font-size: 12px;
}
.tab > span {
width: 18px;
height: 18px;
font-size: 9px;
}
.tab[aria-selected='true']::after {
left: 10px;
right: 10px;
}
.panel {
padding: 24px;
grid-template-columns: 1fr;
gap: 25px;
}
.panel h2 {
font-size: 32px;
}
.panel-art {
min-height: 220px;
}
.panel-notes {
grid-column: auto;
}
.panel .description {
font-size: 14px;
}
.keyboard-hint {
line-height: 1.9;
}
.footer {
flex-wrap: wrap;
}
}
@media (max-width: 360px) {
.tab > span {
display: none;
}
.panel {
padding: 22px;
}
.tab {
font-size: 12px;
}
.panel h2 {
font-size: 29px;
}
}
</style>
</head>
<body>
<header class="wrap page-header">
<span class="brand"
><span class="brand-mark" aria-hidden="true">m.</span>MRHTML
Workshop</span
>
<p class="header-note">A small guide to thoughtful work.</p>
</header>
<main class="wrap" id="main">
<div class="intro">
<p class="eyebrow">A practical creative process</p>
<h1>From first idea<br /><span>to final detail.</span></h1>
<p>
Good work takes a few different kinds of thinking. Explore each stage
to see what it brings to the process.
</p>
</div>
<div class="workspace">
<div
class="tab-list"
id="process-tabs"
role="tablist"
aria-label="Stages of the creative process"
hidden
>
<button
class="tab"
id="tab-explore"
type="button"
role="tab"
aria-controls="panel-explore"
aria-selected="true"
tabindex="0"
>
<span aria-hidden="true">1</span>Explore</button
><button
class="tab"
id="tab-build"
type="button"
role="tab"
aria-controls="panel-build"
aria-selected="false"
tabindex="-1"
>
<span aria-hidden="true">2</span>Build</button
><button
class="tab"
id="tab-refine"
type="button"
role="tab"
aria-controls="panel-refine"
aria-selected="false"
tabindex="-1"
>
<span aria-hidden="true">3</span>Refine
</button>
</div>
<section
class="panel"
id="panel-explore"
aria-labelledby="heading-explore"
>
<div>
<p class="eyebrow">01 / Find the right question</p>
<h2 id="heading-explore">Make space for possibility.</h2>
<p class="description">
Understand the people and the problem before settling on a
solution. A little curiosity can change the direction of a
project.
</p>
<ul class="checklist">
<li>Write down the problem in plain language.</li>
<li>Talk to the people who will use the result.</li>
<li>Sketch a few different ways forward.</li>
</ul>
</div>
<div
class="panel-art"
role="img"
aria-label="Two overlapping idea cards with a blue circular mark"
>
<div class="sketch-card">
<span class="sketch-dot"></span><span class="sketch-line"></span
><span class="sketch-line"></span>
</div>
<span class="art-caption">START WITH A QUESTION.</span>
</div>
<details class="panel-notes">
<summary>
A useful starting question <span aria-hidden="true">+</span>
</summary>
<p>
What would become easier for someone if this project succeeded?
Keep the answer nearby as you compare ideas.
</p>
</details>
</section>
<section class="panel" id="panel-build" aria-labelledby="heading-build">
<div>
<p class="eyebrow">02 / Make the idea tangible</p>
<h2 id="heading-build">Give good thinking a shape.</h2>
<p class="description">
Build the smallest useful version. A working example makes
assumptions visible and gives everyone something concrete to
discuss.
</p>
<ul class="checklist">
<li>Start with structure and real content.</li>
<li>Make the main interaction work first.</li>
<li>Keep the pieces simple enough to change.</li>
</ul>
</div>
<div
class="panel-art build-art"
role="img"
aria-label="A small browser wireframe with a green hero and two content cards"
>
<div class="browser-card">
<div class="browser-top"><i></i><i></i><i></i></div>
<div class="browser-layout"><i></i><i></i><i></i></div>
</div>
<span class="art-caption">SMALL ENOUGH TO LEARN FROM.</span>
</div>
<details class="panel-notes">
<summary>
A useful prototype boundary <span aria-hidden="true">+</span>
</summary>
<p>
Pick one task a person should be able to complete. Build enough of
the experience to test that task, and be clear about what is still
illustrative.
</p>
</details>
</section>
<section
class="panel"
id="panel-refine"
aria-labelledby="heading-refine"
>
<div>
<p class="eyebrow">03 / Pay attention to the details</p>
<h2 id="heading-refine">Make the useful feel effortless.</h2>
<p class="description">
Watch someone use the result. Refine the places where they
hesitate, and check the experience across screens and input
methods.
</p>
<ul class="checklist">
<li>Test a complete keyboard journey.</li>
<li>Read every label and error message.</li>
<li>Check small screens and reduced motion.</li>
</ul>
</div>
<div
class="panel-art refine-art"
role="img"
aria-label="Three concentric circles with a blue center"
>
<div class="target"><span></span></div>
<span class="art-caption">CLEARER WITH EVERY PASS.</span>
</div>
<details class="panel-notes">
<summary>
A useful finishing check <span aria-hidden="true">+</span>
</summary>
<p>
Ask someone unfamiliar with the project to try the main task.
Their questions can reveal more than another round of visual
polishing.
</p>
</details>
</section>
</div>
<p class="keyboard-hint" id="keyboard-hint" hidden>
On the tabs, use <kbd>←</kbd> <kbd>→</kbd> to change stages,
<kbd>Home</kbd> or <kbd>End</kbd> to jump, and <kbd>Tab</kbd> to enter
the selected panel.
</p>
</main>
<footer class="wrap footer">
<span>MRHTML / Original tabs example</span
><span>Three stages. One clear place to focus.</span>
</footer>
<script>
// MRHTML: every panel is readable until this progressive enhancement runs.
const tablist = document.getElementById('process-tabs');
const tabs = [...tablist.querySelectorAll('[role="tab"]')];
const panels = tabs.map((tab) =>
document.getElementById(tab.getAttribute('aria-controls')),
);
const activate = (selected) => {
tabs.forEach((tab, index) => {
const active = tab === selected;
tab.setAttribute('aria-selected', String(active));
tab.tabIndex = active ? 0 : -1;
panels[index].hidden = !active;
});
};
tabs.forEach((tab, index) => {
panels[index].setAttribute('role', 'tabpanel');
panels[index].setAttribute('aria-labelledby', tab.id);
// The panel begins with meaningful noninteractive text, so it gets a Tab stop.
panels[index].tabIndex = 0;
tab.addEventListener('focus', () => activate(tab));
tab.addEventListener('click', () => {
activate(tab);
tab.focus();
});
tab.addEventListener('keydown', (event) => {
let next;
if (event.key === 'ArrowRight') next = (index + 1) % tabs.length;
else if (event.key === 'ArrowLeft')
next = (index - 1 + tabs.length) % tabs.length;
else if (event.key === 'Home') next = 0;
else if (event.key === 'End') next = tabs.length - 1;
else return;
event.preventDefault();
tabs[next].focus();
});
});
activate(tabs[0]);
tablist.hidden = false;
document.getElementById('keyboard-hint').hidden = false;
</script>
</body>
</html>