Responsive Breakpoint Preview
Drag a width slider and watch one layout change from one to two to three columns and from a menu icon to a full nav.
AI prompt
Responsive design diagram showing the same web page at three widths side by side: a narrow phone layout with a hamburger icon and one stacked column of six cards, a medium tablet layout with two columns, and a wide desktop layout with a full navigation bar and three columns, consistent card content and colours, labelled Narrow, Medium and Wide, flat vector style, light theme. Negative: different content per layout, device mockup frames, gradients, text errors. Reduced motion: static diagram.About this pattern
Definition
A responsive layout rearranges itself as the available width changes. At narrow widths content stacks and navigation collapses to an icon; as space grows, columns appear and the full navigation shows. Container queries let a component respond to its own width, not just the window.
Purpose & UX principles
- Design the narrow layout first and add columns as space allows (mobile first).
- Choose breakpoints where the content breaks, not at fixed device widths.
- Keep reading order the same in every layout.
Interaction states
- A Width slider and three quick buttons (Narrow, Medium, Wide) with the current layout named.
Motion specification
- The layout reflows as you drag; no animation.
- Reduced motion: nothing to change.
Responsive behaviour
- Test the in-between widths, not just three named sizes.
- Never hide essential content at small sizes; reorder or collapse it.
Code
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Preset"><button data-p="0" aria-pressed="true">Narrow</button><button data-p="1" aria-pressed="false">Medium</button><button data-p="2" aria-pressed="false">Wide</button></div><label class="rw">Width <b id="wv">262px</b><input id="wd" type="range" min="200" max="316" value="262"></label><div class="fr" id="fr"><div class="pg" id="pg"><header><b>Brand</b><button type="button" class="bg" aria-label="Menu">☰</button><nav><a>Docs</a><a>Pricing</a><a>About</a></nav></header><div class="gd"><i></i><i></i><i></i><i></i><i></i><i></i></div></div></div><p class="out" id="out" aria-live="polite"></p></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.fr{border:1px dashed var(--line);border-radius:10px;padding:6px;background:var(--pv)}.pg{container-type:inline-size;margin:0 auto;background:var(--surface);border:1px solid var(--line);border-radius:8px;overflow:hidden}
.pg header{display:flex;align-items:center;justify-content:space-between;padding:7px 10px;border-bottom:1px solid var(--line);font-size:12px}.pg nav{display:none;gap:12px;color:var(--muted)}.bg{font-size:16px}
.gd{display:grid;grid-template-columns:1fr;gap:6px;padding:8px}.gd i{height:22px;border-radius:5px;background:linear-gradient(90deg,#d8dfec,#eef1f7)}
@container (min-width:260px){.gd{grid-template-columns:1fr 1fr}.gd i{height:34px}}
@container (min-width:300px){.gd{grid-template-columns:1fr 1fr 1fr}.pg nav{display:flex}.bg{display:none}}
.out{font-size:12px;color:var(--muted)}.out b{color:var(--text)}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const P=[210,262,316],wd=document.getElementById('wd'),pg=document.getElementById('pg'),bs=[...document.querySelectorAll('#pre button')];
function up(){const w=+wd.value;pg.style.width=w+'px';document.getElementById('wv').textContent=w+'px';const l=w>=300?'3 columns, full navigation':w>=260?'2 columns, menu icon':'1 column, menu icon';document.getElementById('out').innerHTML='<b>Layout:</b> '+l;bs.forEach(b=>b.setAttribute('aria-pressed',String(P[+b.dataset.p]===w)));}
bs.forEach(b=>b.addEventListener('click',()=>{wd.value=P[+b.dataset.p];up();}));wd.addEventListener('input',up);up();One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Responsive Breakpoint Preview — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.fr{border:1px dashed var(--line);border-radius:10px;padding:6px;background:var(--pv)}.pg{container-type:inline-size;margin:0 auto;background:var(--surface);border:1px solid var(--line);border-radius:8px;overflow:hidden}
.pg header{display:flex;align-items:center;justify-content:space-between;padding:7px 10px;border-bottom:1px solid var(--line);font-size:12px}.pg nav{display:none;gap:12px;color:var(--muted)}.bg{font-size:16px}
.gd{display:grid;grid-template-columns:1fr;gap:6px;padding:8px}.gd i{height:22px;border-radius:5px;background:linear-gradient(90deg,#d8dfec,#eef1f7)}
@container (min-width:260px){.gd{grid-template-columns:1fr 1fr}.gd i{height:34px}}
@container (min-width:300px){.gd{grid-template-columns:1fr 1fr 1fr}.pg nav{display:flex}.bg{display:none}}
.out{font-size:12px;color:var(--muted)}.out b{color:var(--text)}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Preset"><button data-p="0" aria-pressed="true">Narrow</button><button data-p="1" aria-pressed="false">Medium</button><button data-p="2" aria-pressed="false">Wide</button></div><label class="rw">Width <b id="wv">262px</b><input id="wd" type="range" min="200" max="316" value="262"></label><div class="fr" id="fr"><div class="pg" id="pg"><header><b>Brand</b><button type="button" class="bg" aria-label="Menu">☰</button><nav><a>Docs</a><a>Pricing</a><a>About</a></nav></header><div class="gd"><i></i><i></i><i></i><i></i><i></i><i></i></div></div></div><p class="out" id="out" aria-live="polite"></p></div>
</div>
<script>
const P=[210,262,316],wd=document.getElementById('wd'),pg=document.getElementById('pg'),bs=[...document.querySelectorAll('#pre button')];
function up(){const w=+wd.value;pg.style.width=w+'px';document.getElementById('wv').textContent=w+'px';const l=w>=300?'3 columns, full navigation':w>=260?'2 columns, menu icon':'1 column, menu icon';document.getElementById('out').innerHTML='<b>Layout:</b> '+l;bs.forEach(b=>b.setAttribute('aria-pressed',String(P[+b.dataset.p]===w)));}
bs.forEach(b=>b.addEventListener('click',()=>{wd.value=P[+b.dataset.p];up();}));wd.addEventListener('input',up);up();
</script>
</body></html>