Outline to Fill Text Sweep
Outlined headline letters that fill with solid colour in a sweep, with direction choices and hover or focus triggers.
AI prompt
Typographic poster of the word FILL set in a very heavy sans-serif, the letters hollow with a thin black outline on the right half and solid black filled on the left half with a crisp vertical edge between them, as if a fill is sweeping from left to right, off-white background, small arrow icon at the edge. Variants: sweeping from the bottom upward and radial from the centre. Negative: gradients, shadows, clutter, text errors. Reduced motion: solid fill only.About this pattern
Definition
An outlined word has a hollow, graphic feel. Sweeping a solid fill through it turns that outline into a solid shape and gives hover and scroll moments a strong accent. It is built with transparent text, a text stroke and a clipped background whose edge moves.
When to use it
- Use a heavy font so the outline has room; set color to transparent and -webkit-text-stroke to about 1.5px.
- Paint a hard-edged linear gradient on the background and clip it to the text.
- Move the stop with a custom property or a background-size transition.
- Trigger on hover and on keyboard focus.
What the controls do
- Direction buttons; hover, focus or press Play to run the sweep.
Motion & timing
- The sweep takes 700ms.
- Reduced motion: the text fills instantly.
Tips & variations
- Keep a plain solid fallback colour for browsers that do not support text stroke or background clip.
- Outline-only text can have low contrast; make the final state solid and strong.
Code of this live preview
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Direction"><button data-p="0" aria-pressed="true">Left to right</button><button data-p="1" aria-pressed="false">Bottom to top</button><button data-p="2" aria-pressed="false">From centre</button></div><button class="wd" id="wd" type="button" aria-label="FILL"><span id="wt">FILL</span></button><button class="mini" id="pl" type="button">Play</button></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}
.wd{display:grid;place-items:center;width:100%;height:100px;border-radius:12px;background:var(--surface);border:1px solid var(--line)}.wd span{font:900 62px/1 system-ui,'Arial Black',sans-serif;letter-spacing:.02em;color:transparent;-webkit-text-stroke:1.6px #171717;background:var(--bg) 0 0/100% 100% no-repeat;-webkit-background-clip:text;background-clip:text}.mini{height:30px;padding:0 14px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:12px;font-weight:600;cursor:pointer}.mini:disabled{opacity:.4;cursor:default}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const wt=document.getElementById('wt'),wd=document.getElementById('wd'),bs=[...document.querySelectorAll('#pre button')],calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let p=0,raf=0,k=0;
function paint(v){const c='#171717',t='transparent';wt.style.setProperty('--bg',p===0?'linear-gradient(90deg,'+c+' '+v*100+'%,'+t+' '+v*100+'%)':p===1?'linear-gradient(0deg,'+c+' '+v*100+'%,'+t+' '+v*100+'%)':'radial-gradient(circle at 50% 50%,'+c+' '+v*75+'%,'+t+' '+v*75+'%)');}
function to(a,b){cancelAnimationFrame(raf);if(calm){k=b;paint(b);return;}const t0=performance.now();(function f(n){const q=Math.min(1,(n-t0)/700),e=q<.5?2*q*q:1-Math.pow(-2*q+2,2)/2;k=a+(b-a)*e;paint(k);if(q<1)raf=requestAnimationFrame(f);})(t0);}
['mouseenter','focus'].forEach(t=>wd.addEventListener(t,()=>to(k,1)));['mouseleave','blur'].forEach(t=>wd.addEventListener(t,()=>to(k,0)));
document.getElementById('pl').addEventListener('click',()=>{k=0;paint(0);to(0,1);});bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;bs.forEach(x=>x.setAttribute('aria-pressed',String(x===b)));k=0;paint(0);to(0,1);}));paint(0);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>Outline to Fill Text Sweep — 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}
.wd{display:grid;place-items:center;width:100%;height:100px;border-radius:12px;background:var(--surface);border:1px solid var(--line)}.wd span{font:900 62px/1 system-ui,'Arial Black',sans-serif;letter-spacing:.02em;color:transparent;-webkit-text-stroke:1.6px #171717;background:var(--bg) 0 0/100% 100% no-repeat;-webkit-background-clip:text;background-clip:text}.mini{height:30px;padding:0 14px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:12px;font-weight:600;cursor:pointer}.mini:disabled{opacity:.4;cursor:default}
@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="Direction"><button data-p="0" aria-pressed="true">Left to right</button><button data-p="1" aria-pressed="false">Bottom to top</button><button data-p="2" aria-pressed="false">From centre</button></div><button class="wd" id="wd" type="button" aria-label="FILL"><span id="wt">FILL</span></button><button class="mini" id="pl" type="button">Play</button></div>
</div>
<script>
const wt=document.getElementById('wt'),wd=document.getElementById('wd'),bs=[...document.querySelectorAll('#pre button')],calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let p=0,raf=0,k=0;
function paint(v){const c='#171717',t='transparent';wt.style.setProperty('--bg',p===0?'linear-gradient(90deg,'+c+' '+v*100+'%,'+t+' '+v*100+'%)':p===1?'linear-gradient(0deg,'+c+' '+v*100+'%,'+t+' '+v*100+'%)':'radial-gradient(circle at 50% 50%,'+c+' '+v*75+'%,'+t+' '+v*75+'%)');}
function to(a,b){cancelAnimationFrame(raf);if(calm){k=b;paint(b);return;}const t0=performance.now();(function f(n){const q=Math.min(1,(n-t0)/700),e=q<.5?2*q*q:1-Math.pow(-2*q+2,2)/2;k=a+(b-a)*e;paint(k);if(q<1)raf=requestAnimationFrame(f);})(t0);}
['mouseenter','focus'].forEach(t=>wd.addEventListener(t,()=>to(k,1)));['mouseleave','blur'].forEach(t=>wd.addEventListener(t,()=>to(k,0)));
document.getElementById('pl').addEventListener('click',()=>{k=0;paint(0);to(0,1);});bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;bs.forEach(x=>x.setAttribute('aria-pressed',String(x===b)));k=0;paint(0);to(0,1);}));paint(0);
</script>
</body></html>