Frosted Nav Bar on Scroll
A sticky nav bar that starts clear and turns frosted, with a hairline, once content scrolls under it.
AI prompt
Clean UI mockup of a web page scrolled slightly, the top navigation bar frosted glass with a blurred translucent white background showing soft blurred colour blocks passing underneath, a thin hairline bottom border, logo on the left and three links and a small button on the right, below it colourful content cards partially hidden behind the bar, light theme, flat modern style. Negative: heavy shadows, clutter, text errors, device frames. Reduced motion: static design.About this pattern
Definition
A frosted nav bar blurs whatever scrolls beneath it, so the bar stays readable while still letting colour show through. At the top of the page it is usually plain and transparent; after the first few pixels of scroll it picks up blur, a tint and a thin bottom border that separates it from the content.
Purpose & UX principles
- Use position sticky with backdrop-filter: blur(12px) saturate(1.4) and a semi-transparent background.
- Add the frosted class after about 8 pixels of scroll, using a scroll listener or an IntersectionObserver sentinel.
- Add a 1px bottom border or shadow only in the scrolled state.
- Provide a solid fallback background when backdrop-filter is unsupported.
Interaction states
- Scroll the page area; switch blur and border on or off.
Motion specification
- The change takes 200ms.
- Reduced motion: no transition.
Responsive behaviour
- Blurred backgrounds still need enough text contrast against whatever passes underneath.
- Large blurs on big areas cost performance on low-end devices.
Code
<div class="bx"><div class="sc" id="sc"><nav class="nv" id="nv"><b>Studio</b><span>Work</span><span>About</span><span>Contact</span></nav><div class="ct"><i style="background:#ff8a65"></i><i style="background:#4db6ac"></i><i style="background:#7986cb"></i><i style="background:#ffd54f"></i><i style="background:#f06292"></i></div></div><div class="two"><label class="sw"><input id="bl" type="checkbox" checked> Blur</label><label class="sw"><input id="bd" type="checkbox" checked> Hairline border</label></div></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}
.sc{height:170px;overflow:auto;border-radius:12px;border:1px solid var(--line);position:relative;background:#fff}.nv{position:sticky;top:0;z-index:2;display:flex;gap:14px;align-items:center;padding:10px 14px;font-size:12px;transition:background .2s,backdrop-filter .2s,border-color .2s;border-bottom:1px solid transparent}.nv b{margin-right:auto;font-size:14px}.nv.fr{background:rgba(255,255,255,.55);border-bottom-color:transparent}.nv.fr.bl{-webkit-backdrop-filter:blur(12px) saturate(1.5);backdrop-filter:blur(12px) saturate(1.5)}.nv.fr:not(.bl){background:rgba(255,255,255,.95)}.nv.fr.bd{border-bottom-color:rgba(0,0,0,.12)}.ct{margin-top:-40px;display:grid;gap:10px;padding:46px 12px 12px}.ct i{display:block;height:80px;border-radius:12px}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}.sw{display:flex;gap:6px;align-items:center;font-size:12px;color:var(--muted)}@media (prefers-reduced-motion:reduce){.nv{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const sc=document.getElementById('sc'),nv=document.getElementById('nv'),bl=document.getElementById('bl'),bd=document.getElementById('bd');
function up(){nv.classList.toggle('fr',sc.scrollTop>8);nv.classList.toggle('bl',bl.checked);nv.classList.toggle('bd',bd.checked);}
sc.addEventListener('scroll',up);bl.addEventListener('change',up);bd.addEventListener('change',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>Frosted Nav Bar on Scroll — 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}
.sc{height:170px;overflow:auto;border-radius:12px;border:1px solid var(--line);position:relative;background:#fff}.nv{position:sticky;top:0;z-index:2;display:flex;gap:14px;align-items:center;padding:10px 14px;font-size:12px;transition:background .2s,backdrop-filter .2s,border-color .2s;border-bottom:1px solid transparent}.nv b{margin-right:auto;font-size:14px}.nv.fr{background:rgba(255,255,255,.55);border-bottom-color:transparent}.nv.fr.bl{-webkit-backdrop-filter:blur(12px) saturate(1.5);backdrop-filter:blur(12px) saturate(1.5)}.nv.fr:not(.bl){background:rgba(255,255,255,.95)}.nv.fr.bd{border-bottom-color:rgba(0,0,0,.12)}.ct{margin-top:-40px;display:grid;gap:10px;padding:46px 12px 12px}.ct i{display:block;height:80px;border-radius:12px}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}.sw{display:flex;gap:6px;align-items:center;font-size:12px;color:var(--muted)}@media (prefers-reduced-motion:reduce){.nv{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="sc" id="sc"><nav class="nv" id="nv"><b>Studio</b><span>Work</span><span>About</span><span>Contact</span></nav><div class="ct"><i style="background:#ff8a65"></i><i style="background:#4db6ac"></i><i style="background:#7986cb"></i><i style="background:#ffd54f"></i><i style="background:#f06292"></i></div></div><div class="two"><label class="sw"><input id="bl" type="checkbox" checked> Blur</label><label class="sw"><input id="bd" type="checkbox" checked> Hairline border</label></div></div>
</div>
<script>
const sc=document.getElementById('sc'),nv=document.getElementById('nv'),bl=document.getElementById('bl'),bd=document.getElementById('bd');
function up(){nv.classList.toggle('fr',sc.scrollTop>8);nv.classList.toggle('bl',bl.checked);nv.classList.toggle('bd',bd.checked);}
sc.addEventListener('scroll',up);bl.addEventListener('change',up);bd.addEventListener('change',up);up();
</script>
</body></html>