Text Weight Proximity Hover
Each letter grows heavier and lifts as the pointer comes near, falling off smoothly with distance.
AI prompt
Typographic poster of the word Proximity set in a large rounded sans-serif, the letters near the centre much heavier, taller and slightly raised, fading smoothly to light thin letters at both ends, as if a soft invisible wave passes under the word, off-white background, near-black type, a small cursor arrow icon near the heaviest letter. Negative: gradients, shadows, clutter, text errors. Reduced motion: still poster.About this pattern
Definition
A proximity effect makes type react to the cursor. Every letter measures its distance to the pointer and sets its own weight, size or lift from that number, so a soft wave follows the mouse across the word. It turns a headline into something you can feel without any click.
When to use it
- Split the text into letter spans; keep the full word readable to screen readers with an aria-label on the container.
- On pointer move compute each letter's distance and map it with a smooth falloff to weight, scale and lift.
- Update styles only, never rebuild elements, and use requestAnimationFrame.
- Reset gently when the pointer leaves.
What the controls do
- Move the pointer or touch across the word; choose the effect and radius.
Motion & timing
- Letters follow the pointer with a 120ms ease.
- Reduced motion: letters stay still.
Tips & variations
- Fonts without variable weight axes show only two or three steps; use scale and lift too.
- Keep layout stable: use transforms, and give letters a fixed width cell if weight changes shape.
Code of this live preview
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Effect"><button data-p="0" aria-pressed="true">Weight</button><button data-p="1" aria-pressed="false">Lift</button><button data-p="2" aria-pressed="false">Both</button></div><div class="tz" id="tz" role="group" aria-label="Proximity"></div><label class="rw">Radius <b id="rv">90px</b><input id="rs" type="range" min="40" max="160" value="90"></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}
.tz{height:110px;border-radius:12px;background:var(--surface);border:1px solid var(--line);display:flex;align-items:center;justify-content:center;font:300 40px/1 system-ui,sans-serif;letter-spacing:.01em;touch-action:none;overflow:hidden}.tz span{display:inline-block;transition:transform .12s,font-weight .12s;will-change:transform}@media (prefers-reduced-motion:reduce){.tz span{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const W='Proximity',tz=document.getElementById('tz'),rs=document.getElementById('rs'),bs=[...document.querySelectorAll('#pre button')],calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let p=2;tz.setAttribute('aria-label',W);tz.innerHTML=[...W].map(c=>'<span aria-hidden="true">'+c+'</span>').join('');const L=[...tz.children];
function set(x){const R=+rs.value;L.forEach(e=>{const r=e.getBoundingClientRect(),cx=r.left+r.width/2,d=x===null?9999:Math.abs(x-cx),k=Math.max(0,1-d/R),s=k*k*(3-2*k);e.style.fontWeight=(p!==1)?Math.round(300+s*600):300;e.style.transform=(p!==0)?'translateY('+(-s*14)+'px) scale('+(1+s*.25)+')':'none';});}
function up(){document.getElementById('rv').textContent=rs.value+'px';bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();set(null);}));rs.addEventListener('input',up);
if(!calm){tz.addEventListener('pointermove',e=>set(e.clientX));tz.addEventListener('pointerleave',()=>set(null));}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>Text Weight Proximity Hover — 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}
.tz{height:110px;border-radius:12px;background:var(--surface);border:1px solid var(--line);display:flex;align-items:center;justify-content:center;font:300 40px/1 system-ui,sans-serif;letter-spacing:.01em;touch-action:none;overflow:hidden}.tz span{display:inline-block;transition:transform .12s,font-weight .12s;will-change:transform}@media (prefers-reduced-motion:reduce){.tz span{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="Effect"><button data-p="0" aria-pressed="true">Weight</button><button data-p="1" aria-pressed="false">Lift</button><button data-p="2" aria-pressed="false">Both</button></div><div class="tz" id="tz" role="group" aria-label="Proximity"></div><label class="rw">Radius <b id="rv">90px</b><input id="rs" type="range" min="40" max="160" value="90"></label></div>
</div>
<script>
const W='Proximity',tz=document.getElementById('tz'),rs=document.getElementById('rs'),bs=[...document.querySelectorAll('#pre button')],calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let p=2;tz.setAttribute('aria-label',W);tz.innerHTML=[...W].map(c=>'<span aria-hidden="true">'+c+'</span>').join('');const L=[...tz.children];
function set(x){const R=+rs.value;L.forEach(e=>{const r=e.getBoundingClientRect(),cx=r.left+r.width/2,d=x===null?9999:Math.abs(x-cx),k=Math.max(0,1-d/R),s=k*k*(3-2*k);e.style.fontWeight=(p!==1)?Math.round(300+s*600):300;e.style.transform=(p!==0)?'translateY('+(-s*14)+'px) scale('+(1+s*.25)+')':'none';});}
function up(){document.getElementById('rv').textContent=rs.value+'px';bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();set(null);}));rs.addEventListener('input',up);
if(!calm){tz.addEventListener('pointermove',e=>set(e.clientX));tz.addEventListener('pointerleave',()=>set(null));}up();
</script>
</body></html>