Highlighter Marker Sweep
Key words in a sentence are highlighted one after another by a marker stroke that sweeps across, in four colours.
AI prompt
Close-up of a printed paragraph on cream paper with three key phrases highlighted by a yellow marker stroke, each highlight slightly uneven at the ends like real pen, the black text fully legible through the translucent colour, soft side light, shallow depth of field, tactile and editorial. Variants: mint, pink and blue highlighter. Negative: opaque blocks hiding the text, neon colours, text errors, hands. Reduced motion: static image.About this pattern
Definition
A highlighter sweep draws attention to the words that matter. A coloured band grows behind each key phrase from left to right, as if marked with a pen, and the staggered timing guides the eye through the sentence in the intended order.
When to use it
- Highlight two or three phrases at most; more than that and nothing stands out.
- Sweep left to right at about 500ms per phrase with a 250ms gap.
- Keep text contrast high against the highlight; use a light, slightly transparent colour.
What the controls do
- Four colour buttons and a Replay button.
Motion & timing
- Each highlight sweeps in 500ms with a stagger.
- Reduced motion: the highlights appear at once.
Tips & variations
- The highlight is decorative, so the meaning must stand without it.
- Use the mark element so assistive technology knows these words are emphasised.
Code of this live preview
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Colour"><button data-p="0" aria-pressed="true">Yellow</button><button data-p="1" aria-pressed="false">Mint</button><button data-p="2" aria-pressed="false">Pink</button><button data-p="3" aria-pressed="false">Blue</button></div><p class="tx" id="tx">Good design is <mark>not just how it looks</mark> but <mark>how it works</mark>, and the best interfaces make <mark>the right action obvious</mark>.</p><button class="mini" id="rp" type="button">Replay</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}
.tx{font-size:16px;line-height:1.9;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:var(--surface);font-weight:500}.tx mark{color:inherit;background:linear-gradient(var(--hl),var(--hl)) 0 88%/0% 70% no-repeat;transition:background-size .5s ease-out;padding:0 2px;border-radius:2px}.tx mark.on{background-size:100% 70%}
.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){.tx mark{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const H=['rgba(255,214,10,.65)','rgba(110,231,183,.7)','rgba(255,150,190,.65)','rgba(120,180,255,.65)'],tx=document.getElementById('tx'),ms=[...tx.querySelectorAll('mark')],bs=[...document.querySelectorAll('#pre button')],calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let p=0,tm=[];
function run(){tm.forEach(clearTimeout);tm=[];ms.forEach(m=>m.classList.remove('on'));tx.style.setProperty('--hl',H[p]);bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));ms.forEach((m,i)=>tm.push(setTimeout(()=>m.classList.add('on'),calm?0:250+i*750)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;run();}));document.getElementById('rp').addEventListener('click',run);run();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>Highlighter Marker 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}
.tx{font-size:16px;line-height:1.9;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:var(--surface);font-weight:500}.tx mark{color:inherit;background:linear-gradient(var(--hl),var(--hl)) 0 88%/0% 70% no-repeat;transition:background-size .5s ease-out;padding:0 2px;border-radius:2px}.tx mark.on{background-size:100% 70%}
.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){.tx mark{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="Colour"><button data-p="0" aria-pressed="true">Yellow</button><button data-p="1" aria-pressed="false">Mint</button><button data-p="2" aria-pressed="false">Pink</button><button data-p="3" aria-pressed="false">Blue</button></div><p class="tx" id="tx">Good design is <mark>not just how it looks</mark> but <mark>how it works</mark>, and the best interfaces make <mark>the right action obvious</mark>.</p><button class="mini" id="rp" type="button">Replay</button></div>
</div>
<script>
const H=['rgba(255,214,10,.65)','rgba(110,231,183,.7)','rgba(255,150,190,.65)','rgba(120,180,255,.65)'],tx=document.getElementById('tx'),ms=[...tx.querySelectorAll('mark')],bs=[...document.querySelectorAll('#pre button')],calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let p=0,tm=[];
function run(){tm.forEach(clearTimeout);tm=[];ms.forEach(m=>m.classList.remove('on'));tx.style.setProperty('--hl',H[p]);bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));ms.forEach((m,i)=>tm.push(setTimeout(()=>m.classList.add('on'),calm?0:250+i*750)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;run();}));document.getElementById('rp').addEventListener('click',run);run();
</script>
</body></html>