Glass Card Edge Highlight
A frosted card whose border catches light from a chosen angle, with angle and blur controls.
AI prompt
Close-up UI render of a frosted glass card floating over soft blurred magenta, blue and orange shapes, the card's thin border brightest along the top left edge and fading to almost nothing at the bottom right as if lit from above left, a faint inner highlight along the top, soft shadow below, a title and two lines of text inside, light theme, premium style. Negative: heavy outlines, flat colour card, noisy backgrounds, text errors. Reduced motion: still image.About this pattern
Definition
Real glass has brighter edges where light hits its bevel. A frosted card feels more physical when the border is a gradient that is bright on the side facing the light and faint on the opposite side. The gradient border is drawn with a masked pseudo-element, so the card stays translucent inside.
Purpose & UX principles
- Fill the card with a translucent white and a backdrop blur.
- Add a ::before with a linear or conic gradient, then mask out its centre with mask-composite so only a one to two pixel ring shows.
- Rotate the gradient angle to move the highlight; keep light direction consistent across cards.
- Add a faint inner top highlight and a soft shadow underneath.
Interaction states
- An Angle slider, a Blur slider and a background choice.
Motion specification
- Updates are immediate.
- Reduced motion: nothing animates.
Responsive behaviour
- Backdrop blur is expensive; limit the number of glass cards on one screen.
- Check text contrast against the busiest part of the background.
Code
<div class="bx"><div class="st" id="st"><i class="b1"></i><i class="b2"></i><i class="b3"></i><div class="gc"><b>Glass card</b><span>Edge light from the top left.</span></div></div><div class="two"><label class="rw">Light angle <b id="av">315°</b><input id="as" type="range" min="0" max="360" value="315"></label><label class="rw">Blur <b id="bv">14px</b><input id="bs" type="range" min="0" max="30" value="14"></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}
.st{position:relative;height:140px;border-radius:12px;overflow:hidden;background:#201a3a;display:grid;place-items:center}.st i{position:absolute;display:block;border-radius:50%;filter:blur(2px)}.b1{left:12%;top:8%;width:90px;height:90px;background:#ff4fa3}.b2{right:10%;bottom:6%;width:110px;height:110px;background:#4f7bff}.b3{left:42%;top:52%;width:70px;height:70px;background:#ffa84f}.gc{position:relative;width:190px;padding:14px 16px;border-radius:18px;background:rgba(255,255,255,.14);-webkit-backdrop-filter:blur(var(--bl,14px));backdrop-filter:blur(var(--bl,14px));color:#fff;display:grid;gap:3px;box-shadow:0 12px 30px rgba(0,0,0,.35),inset 0 1px 0 rgba(255,255,255,.35)}.gc::before{content:"";position:absolute;inset:0;border-radius:inherit;padding:1.5px;background:conic-gradient(from calc(var(--an,315deg) - 45deg) at 50% 50%,rgba(255,255,255,.05),rgba(255,255,255,.95) 45deg,rgba(255,255,255,.05) 120deg,rgba(255,255,255,.05));-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0);mask-composite:exclude;pointer-events:none}.gc b{font-size:15px}.gc span{font-size:12px;opacity:.85}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const st=document.getElementById('st'),as=document.getElementById('as'),bs=document.getElementById('bs');
function up(){st.style.setProperty('--an',as.value+'deg');st.style.setProperty('--bl',bs.value+'px');document.getElementById('av').textContent=as.value+'\u00b0';document.getElementById('bv').textContent=bs.value+'px';}
as.addEventListener('input',up);bs.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>Glass Card Edge Highlight — 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}
.st{position:relative;height:140px;border-radius:12px;overflow:hidden;background:#201a3a;display:grid;place-items:center}.st i{position:absolute;display:block;border-radius:50%;filter:blur(2px)}.b1{left:12%;top:8%;width:90px;height:90px;background:#ff4fa3}.b2{right:10%;bottom:6%;width:110px;height:110px;background:#4f7bff}.b3{left:42%;top:52%;width:70px;height:70px;background:#ffa84f}.gc{position:relative;width:190px;padding:14px 16px;border-radius:18px;background:rgba(255,255,255,.14);-webkit-backdrop-filter:blur(var(--bl,14px));backdrop-filter:blur(var(--bl,14px));color:#fff;display:grid;gap:3px;box-shadow:0 12px 30px rgba(0,0,0,.35),inset 0 1px 0 rgba(255,255,255,.35)}.gc::before{content:"";position:absolute;inset:0;border-radius:inherit;padding:1.5px;background:conic-gradient(from calc(var(--an,315deg) - 45deg) at 50% 50%,rgba(255,255,255,.05),rgba(255,255,255,.95) 45deg,rgba(255,255,255,.05) 120deg,rgba(255,255,255,.05));-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0);mask-composite:exclude;pointer-events:none}.gc b{font-size:15px}.gc span{font-size:12px;opacity:.85}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="st" id="st"><i class="b1"></i><i class="b2"></i><i class="b3"></i><div class="gc"><b>Glass card</b><span>Edge light from the top left.</span></div></div><div class="two"><label class="rw">Light angle <b id="av">315°</b><input id="as" type="range" min="0" max="360" value="315"></label><label class="rw">Blur <b id="bv">14px</b><input id="bs" type="range" min="0" max="30" value="14"></label></div></div>
</div>
<script>
const st=document.getElementById('st'),as=document.getElementById('as'),bs=document.getElementById('bs');
function up(){st.style.setProperty('--an',as.value+'deg');st.style.setProperty('--bl',bs.value+'px');document.getElementById('av').textContent=as.value+'\u00b0';document.getElementById('bv').textContent=bs.value+'px';}
as.addEventListener('input',up);bs.addEventListener('input',up);up();
</script>
</body></html>