Typewriter Cycling Words
A headline that types a word, pauses, deletes it and types the next, with a blinking caret and a speed control.
AI prompt
Clean website hero text on a pale background reading We design followed by the word interfaces typed in a bold accent colour with a thin vertical caret after the final letter, the last two letters slightly lighter as if just typed, large sans-serif type, generous margins, flat and minimal. Variants: the word half deleted showing inter, and an empty line with only the caret. Negative: multiple lines, decorative fonts, shadows, text errors. Reduced motion: static headline.About this pattern
Definition
The typewriter effect reveals text one letter at a time with a caret at the end. Cycling words type, hold, delete and move on, so one line can carry several messages without taking more space. The caret blink tells the eye the line is alive.
When to use it
- Type slower than you delete: about 90ms per letter in and 45ms out.
- Hold the finished word for around a second and a half so it can be read.
- Keep the caret blinking at about 1 hertz and a fixed width so the line does not jitter.
What the controls do
- A Speed slider and a Pause button.
Motion & timing
- Typing 90ms per letter, deleting 45ms, hold 1.4s; speed scales all three.
- Reduced motion: the words change every 2s without typing and the caret does not blink.
Tips & variations
- Put the full text in an accessible label once; hide the animated text from screen readers.
- Provide a Pause control; motion that never stops is hard to read.
Code of this live preview
<div class="bx"><div class="hs" role="text" aria-label="We design products, brands and interfaces"><span aria-hidden="true">We design <b id="w"></b><i class="cr"></i></span></div><div class="row2"><label class="rw" style="flex:1">Speed <b id="sv">3</b><input id="sp" type="range" min="1" max="6" value="3"></label><button class="mini" id="pz" type="button" aria-pressed="false">Pause</button></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}
.hs{height:84px;border-radius:12px;background:var(--surface);border:1px solid var(--line);display:grid;place-items:center;font-size:24px;font-weight:700;letter-spacing:-.02em}.hs b{color:#2b59d6}
.cr{display:inline-block;width:2px;height:1em;background:#171717;vertical-align:-3px;margin-left:2px;animation:bl 1s steps(2) infinite}@keyframes bl{50%{opacity:0}}.row2{display:flex;gap:12px;align-items:end}
.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){.cr{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const W=['products','brands','interfaces','systems'],w=document.getElementById('w'),sp=document.getElementById('sp'),pz=document.getElementById('pz'),calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let i=0,n=0,del=false,tm=0,paused=false;
function k(){return 1.6-sp.value*.2;}
function tick(){if(paused)return;const wd=W[i];if(calm){w.textContent=wd;i=(i+1)%W.length;tm=setTimeout(tick,2000);return;}
if(!del){n++;w.textContent=wd.slice(0,n);if(n===wd.length){del=true;tm=setTimeout(tick,1400*k()/1.0);return;}tm=setTimeout(tick,90*k()/1.0);}
else{n--;w.textContent=wd.slice(0,n);if(n===0){del=false;i=(i+1)%W.length;tm=setTimeout(tick,300);return;}tm=setTimeout(tick,45*k());}}
sp.addEventListener('input',()=>document.getElementById('sv').textContent=sp.value);
pz.addEventListener('click',()=>{paused=!paused;pz.setAttribute('aria-pressed',String(paused));pz.textContent=paused?'Play':'Pause';if(!paused){clearTimeout(tm);tick();}});tick();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>Typewriter Cycling Words — 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}
.hs{height:84px;border-radius:12px;background:var(--surface);border:1px solid var(--line);display:grid;place-items:center;font-size:24px;font-weight:700;letter-spacing:-.02em}.hs b{color:#2b59d6}
.cr{display:inline-block;width:2px;height:1em;background:#171717;vertical-align:-3px;margin-left:2px;animation:bl 1s steps(2) infinite}@keyframes bl{50%{opacity:0}}.row2{display:flex;gap:12px;align-items:end}
.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){.cr{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="hs" role="text" aria-label="We design products, brands and interfaces"><span aria-hidden="true">We design <b id="w"></b><i class="cr"></i></span></div><div class="row2"><label class="rw" style="flex:1">Speed <b id="sv">3</b><input id="sp" type="range" min="1" max="6" value="3"></label><button class="mini" id="pz" type="button" aria-pressed="false">Pause</button></div></div>
</div>
<script>
const W=['products','brands','interfaces','systems'],w=document.getElementById('w'),sp=document.getElementById('sp'),pz=document.getElementById('pz'),calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let i=0,n=0,del=false,tm=0,paused=false;
function k(){return 1.6-sp.value*.2;}
function tick(){if(paused)return;const wd=W[i];if(calm){w.textContent=wd;i=(i+1)%W.length;tm=setTimeout(tick,2000);return;}
if(!del){n++;w.textContent=wd.slice(0,n);if(n===wd.length){del=true;tm=setTimeout(tick,1400*k()/1.0);return;}tm=setTimeout(tick,90*k()/1.0);}
else{n--;w.textContent=wd.slice(0,n);if(n===0){del=false;i=(i+1)%W.length;tm=setTimeout(tick,300);return;}tm=setTimeout(tick,45*k());}}
sp.addEventListener('input',()=>document.getElementById('sv').textContent=sp.value);
pz.addEventListener('click',()=>{paused=!paused;pz.setAttribute('aria-pressed',String(paused));pz.textContent=paused?'Play':'Pause';if(!paused){clearTimeout(tm);tick();}});tick();
</script>
</body></html>