Glass Blur Depth
A glass card over moving colour shapes with blur, tint and edge-light controls and three presets.
AI prompt
Product UI render of a frosted glass card floating over three large soft colour orbs in coral, blue and violet, the orbs blurred smoothly where they pass behind the glass and sharp elsewhere, the card slightly white with a thin bright edge highlight along the top, white text Good morning and a small button on it, studio-soft light, depth and calm. Variants: clear glass with only a light blur, and milky glass with heavy blur and tint. Negative: muddy colours, hard shadows, text errors, device frames. Reduced motion: static image.About this pattern
Definition
Glassmorphism puts a translucent, blurred panel over a colourful background. The blur radius sets how frosted it feels, the white tint sets how milky, and a thin bright border on the edge sells the thickness of the glass.
Purpose & UX principles
- backdrop-filter: blur(Npx) saturate(1.4) blurs what is behind the panel.
- A background of rgba white at 10 to 40 percent gives the tint.
- A 1px border at 40 to 60 percent white acts as the glass edge.
- Text on glass must still pass contrast; raise the tint or darken the text if not.
Interaction states
- Three presets, Blur and Tint sliders and an Edge light checkbox; move the pointer to shift the shapes.
Motion specification
- Shapes follow the pointer with a short ease.
- Reduced motion: no easing.
Responsive behaviour
- Fall back to a solid semi-opaque colour where backdrop-filter is unsupported.
- Use blur sparingly; large blurred areas are expensive on low-end phones.
Code
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Preset"><button data-p="0" aria-pressed="true">Frosted</button><button data-p="1" aria-pressed="false">Clear</button><button data-p="2" aria-pressed="false">Milky</button></div><div class="sc" id="sc"><i class="o1"></i><i class="o2"></i><i class="o3"></i><div class="gl" id="gl"><b>Good morning</b><span>Three new updates</span></div></div><div class="two"><label class="rw">Blur <b id="bv">12px</b><input id="bl" type="range" min="0" max="30" value="12"></label><label class="rw">Tint <b id="tv">20%</b><input id="tn" type="range" min="0" max="60" value="20"></label></div><label class="sw"><input id="eg" type="checkbox" checked> Edge light</label></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:130px;border-radius:12px;position:relative;overflow:hidden;background:#eef0f5;display:grid;place-items:center}.sc i{position:absolute;border-radius:50%;display:block;transition:transform .2s ease-out;transform:translate(var(--px,0),var(--py,0))}.o1{width:90px;height:90px;left:10%;top:6%;background:#ff7a6b}.o2{width:100px;height:100px;right:8%;top:20%;background:#4f8cff}.o3{width:80px;height:80px;left:40%;bottom:-8%;background:#9b6bff}
.gl{position:relative;width:70%;height:76px;border-radius:16px;display:grid;align-content:center;gap:2px;padding:0 16px;color:#111;background:rgba(255,255,255,var(--t));backdrop-filter:blur(var(--b)) saturate(1.4);-webkit-backdrop-filter:blur(var(--b)) saturate(1.4);border:1px solid rgba(255,255,255,var(--e))}.gl b{font-size:15px}.gl span{font-size:12px;color:#333}
.sw{display:flex;gap:6px;align-items:center;font-size:12px;color:var(--muted)}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}@media (prefers-reduced-motion:reduce){.sc i{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const PR=[[12,20],[3,8],[24,40]],sc=document.getElementById('sc'),gl=document.getElementById('gl'),bl=document.getElementById('bl'),tn=document.getElementById('tn'),eg=document.getElementById('eg'),bs=[...document.querySelectorAll('#pre button')];let p=0;
function up(){gl.style.setProperty('--b',bl.value+'px');gl.style.setProperty('--t',tn.value/100);gl.style.setProperty('--e',eg.checked?.6:0);document.getElementById('bv').textContent=bl.value+'px';document.getElementById('tv').textContent=tn.value+'%';}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;bl.value=PR[p][0];tn.value=PR[p][1];bs.forEach(k=>k.setAttribute('aria-pressed',String(k===b)));up();}));[bl,tn].forEach(i=>i.addEventListener('input',()=>{bs.forEach(k=>k.setAttribute('aria-pressed','false'));up();}));eg.addEventListener('change',up);
sc.addEventListener('pointermove',e=>{const r=sc.getBoundingClientRect();sc.style.setProperty('--px',((e.clientX-r.left)/r.width-.5)*40+'px');sc.style.setProperty('--py',((e.clientY-r.top)/r.height-.5)*30+'px');});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>Glass Blur Depth — 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:130px;border-radius:12px;position:relative;overflow:hidden;background:#eef0f5;display:grid;place-items:center}.sc i{position:absolute;border-radius:50%;display:block;transition:transform .2s ease-out;transform:translate(var(--px,0),var(--py,0))}.o1{width:90px;height:90px;left:10%;top:6%;background:#ff7a6b}.o2{width:100px;height:100px;right:8%;top:20%;background:#4f8cff}.o3{width:80px;height:80px;left:40%;bottom:-8%;background:#9b6bff}
.gl{position:relative;width:70%;height:76px;border-radius:16px;display:grid;align-content:center;gap:2px;padding:0 16px;color:#111;background:rgba(255,255,255,var(--t));backdrop-filter:blur(var(--b)) saturate(1.4);-webkit-backdrop-filter:blur(var(--b)) saturate(1.4);border:1px solid rgba(255,255,255,var(--e))}.gl b{font-size:15px}.gl span{font-size:12px;color:#333}
.sw{display:flex;gap:6px;align-items:center;font-size:12px;color:var(--muted)}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}@media (prefers-reduced-motion:reduce){.sc i{transition:none}}
@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">Frosted</button><button data-p="1" aria-pressed="false">Clear</button><button data-p="2" aria-pressed="false">Milky</button></div><div class="sc" id="sc"><i class="o1"></i><i class="o2"></i><i class="o3"></i><div class="gl" id="gl"><b>Good morning</b><span>Three new updates</span></div></div><div class="two"><label class="rw">Blur <b id="bv">12px</b><input id="bl" type="range" min="0" max="30" value="12"></label><label class="rw">Tint <b id="tv">20%</b><input id="tn" type="range" min="0" max="60" value="20"></label></div><label class="sw"><input id="eg" type="checkbox" checked> Edge light</label></div>
</div>
<script>
const PR=[[12,20],[3,8],[24,40]],sc=document.getElementById('sc'),gl=document.getElementById('gl'),bl=document.getElementById('bl'),tn=document.getElementById('tn'),eg=document.getElementById('eg'),bs=[...document.querySelectorAll('#pre button')];let p=0;
function up(){gl.style.setProperty('--b',bl.value+'px');gl.style.setProperty('--t',tn.value/100);gl.style.setProperty('--e',eg.checked?.6:0);document.getElementById('bv').textContent=bl.value+'px';document.getElementById('tv').textContent=tn.value+'%';}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;bl.value=PR[p][0];tn.value=PR[p][1];bs.forEach(k=>k.setAttribute('aria-pressed',String(k===b)));up();}));[bl,tn].forEach(i=>i.addEventListener('input',()=>{bs.forEach(k=>k.setAttribute('aria-pressed','false'));up();}));eg.addEventListener('change',up);
sc.addEventListener('pointermove',e=>{const r=sc.getBoundingClientRect();sc.style.setProperty('--px',((e.clientX-r.left)/r.width-.5)*40+'px');sc.style.setProperty('--py',((e.clientY-r.top)/r.height-.5)*30+'px');});up();
</script>
</body></html>