Text on a Path
A line of text runs along a wave, an arc or a loop using SVG textPath, with a speed control and pause.
AI prompt
Kinetic typography poster of the repeating words Keep moving, keep making set along a flowing S-shaped wave across the frame, bold geometric sans-serif letters in near-black on warm off-white, a small coral dot separating each repeat, letters rotating smoothly to follow the curve, generous margins, confident and playful. Variants: the text circling in a full loop, and following a gentle arc. Negative: distorted glyphs, overlapping letters, gradients, clutter, watermark. Reduced motion: static poster.About this pattern
Definition
SVG textPath sets text along any curve. Animating its startOffset slides the text along the path like a marquee on a roller coaster. It is a light way to give type motion and shape without images, and the text stays real, selectable text.
When to use it
- Draw a path, then reference it from a textPath element with href.
- Move the text by animating the startOffset attribute.
- Repeat the phrase with a separator so the path never looks empty.
- Use short, bold phrases; curves make long text hard to read.
What the controls do
- Three curve buttons, a Speed slider and Pause.
Motion & timing
- The text slides continuously along the curve.
- Reduced motion: no sliding; the text is static and Pause is disabled.
Tips & variations
- Provide the same text elsewhere on the page for screen readers.
- Add a pause control for anything that moves continuously.
Code of this live preview
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Curve"><button data-p="0" aria-pressed="true">Wave</button><button data-p="1" aria-pressed="false">Arc</button><button data-p="2" aria-pressed="false">Loop</button></div><svg class="tp" viewBox="0 0 330 120" role="img" aria-label="Text moving along a curve: Keep moving, keep making"><path id="pth" fill="none" stroke="#e0e0dc" stroke-width="1"/><text><textPath id="tx" href="#pth"></textPath></text></svg><div class="two"><label class="rw">Speed <b id="sv">40</b><input id="sp" type="range" min="0" max="100" value="40"></label><button class="mini" id="pz" type="button">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}
.tp{width:100%;height:auto;border:1px solid var(--line);border-radius:12px;background:#fbfaf6}.tp text{font:800 17px system-ui,sans-serif;fill:#171717;letter-spacing:.02em}.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}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const P=['M10 70 C60 10,110 10,165 60 S270 110,320 50','M10 100 Q165 -20 320 100','M165 20 C255 20,300 50,300 80 C300 110,230 110,165 100 C100 110,30 110,30 80 C30 50,75 20,165 20Z'],tx=document.getElementById('tx'),pth=document.getElementById('pth'),sp=document.getElementById('sp'),pz=document.getElementById('pz'),bs=[...document.querySelectorAll('#pre button')],calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let p=0,off=0,paused=calm,last=0;const PH='Keep moving, keep making \u2022 ';
tx.textContent=PH+PH+PH+PH;
function set(){pth.setAttribute('d',P[p]);const L=pth.getTotalLength(),w=L/ (p===2?1:1);tx.setAttribute('startOffset',(-off%(L/3))+'');}
function loop(n){if(!paused){off+=(n-last)/1000*sp.value*1.2;set();}last=n;requestAnimationFrame(loop);}
function up(){document.getElementById('sv').textContent=sp.value;off=0;set();bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();}));sp.addEventListener('input',()=>{document.getElementById('sv').textContent=sp.value;});
pz.addEventListener('click',()=>{paused=!paused;pz.textContent=paused?'Play':'Pause';});if(calm){pz.disabled=true;pz.textContent='Play';sp.disabled=true;}
up();requestAnimationFrame(n=>{last=n;loop(n);});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 on a Path — 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}
.tp{width:100%;height:auto;border:1px solid var(--line);border-radius:12px;background:#fbfaf6}.tp text{font:800 17px system-ui,sans-serif;fill:#171717;letter-spacing:.02em}.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}.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="pre" id="pre" role="group" aria-label="Curve"><button data-p="0" aria-pressed="true">Wave</button><button data-p="1" aria-pressed="false">Arc</button><button data-p="2" aria-pressed="false">Loop</button></div><svg class="tp" viewBox="0 0 330 120" role="img" aria-label="Text moving along a curve: Keep moving, keep making"><path id="pth" fill="none" stroke="#e0e0dc" stroke-width="1"/><text><textPath id="tx" href="#pth"></textPath></text></svg><div class="two"><label class="rw">Speed <b id="sv">40</b><input id="sp" type="range" min="0" max="100" value="40"></label><button class="mini" id="pz" type="button">Pause</button></div></div>
</div>
<script>
const P=['M10 70 C60 10,110 10,165 60 S270 110,320 50','M10 100 Q165 -20 320 100','M165 20 C255 20,300 50,300 80 C300 110,230 110,165 100 C100 110,30 110,30 80 C30 50,75 20,165 20Z'],tx=document.getElementById('tx'),pth=document.getElementById('pth'),sp=document.getElementById('sp'),pz=document.getElementById('pz'),bs=[...document.querySelectorAll('#pre button')],calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let p=0,off=0,paused=calm,last=0;const PH='Keep moving, keep making \u2022 ';
tx.textContent=PH+PH+PH+PH;
function set(){pth.setAttribute('d',P[p]);const L=pth.getTotalLength(),w=L/ (p===2?1:1);tx.setAttribute('startOffset',(-off%(L/3))+'');}
function loop(n){if(!paused){off+=(n-last)/1000*sp.value*1.2;set();}last=n;requestAnimationFrame(loop);}
function up(){document.getElementById('sv').textContent=sp.value;off=0;set();bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();}));sp.addEventListener('input',()=>{document.getElementById('sv').textContent=sp.value;});
pz.addEventListener('click',()=>{paused=!paused;pz.textContent=paused?'Play':'Pause';});if(calm){pz.disabled=true;pz.textContent='Play';sp.disabled=true;}
up();requestAnimationFrame(n=>{last=n;loop(n);});
</script>
</body></html>