Glitch Text Slices
A headline that breaks into offset coloured slices on hover or button press, with an intensity slider.
AI prompt
Typographic poster of the word SIGNAL in heavy white sans-serif on a near-black background, a cyan copy shifted left and a red copy shifted right behind it creating a chromatic split, two thin horizontal bands where the letters are cut and displaced sideways, subtle scan lines, high contrast, cyber style, crisp edges. Negative: blur, gradients, extra words, clutter, text errors. Reduced motion: static design.About this pattern
Definition
Glitch text imitates a broken signal: copies of the word in cyan and red shift sideways while thin horizontal slices of each copy jump out of place. It is built with two pseudo-elements that repeat the text from a data attribute, each clipped to moving bands. Use it rarely, for a short moment, never on body text.
When to use it
- Repeat the text with ::before and ::after using content: attr(data-text).
- Colour them cyan and red and offset them by a few pixels in opposite directions.
- Animate clip-path inset values in steps so slices jump rather than glide.
- Keep the real text in the DOM once, and hide the copies from assistive tech with aria-hidden where possible.
What the controls do
- Hover, focus or press Glitch; adjust Intensity.
Motion & timing
- Each burst lasts about 600ms.
- Reduced motion: a still colour-split with no slicing.
Tips & variations
- Flashing effects can be harmful; keep bursts short and never faster than three flashes per second.
- Reduced motion: show a static offset instead of the animated glitch.
Code of this live preview
<div class="bx"><button class="gl" id="gl" type="button" data-text="SIGNAL"><span>SIGNAL</span></button><div class="two"><label class="rw">Intensity <b id="iv">6px</b><input id="is" type="range" min="1" max="14" value="6"></label><button class="mini" id="bt" type="button">Glitch</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}
.gl{position:relative;display:grid;place-items:center;width:100%;height:110px;border-radius:12px;background:#0d0f14;color:#fff;overflow:hidden;font:900 52px/1 system-ui,'Arial Black',sans-serif;letter-spacing:.04em}.gl span,.gl::before,.gl::after{grid-area:1/1}.gl::before,.gl::after{content:attr(data-text);pointer-events:none;opacity:0}.gl::before{color:#00e5ff;mix-blend-mode:screen}.gl::after{color:#ff2d55;mix-blend-mode:screen}.gl.go::before{opacity:1;animation:g1 .6s steps(1) 1}.gl.go::after{opacity:1;animation:g2 .6s steps(1) 1}.gl.st::before{opacity:1;transform:translateX(calc(var(--i)*-.4px))}.gl.st::after{opacity:1;transform:translateX(calc(var(--i)*.4px))}@keyframes g1{0%{transform:translate(calc(var(--i)*-1px),0);clip-path:inset(10% 0 70% 0)}20%{transform:translate(calc(var(--i)*1px),0);clip-path:inset(60% 0 10% 0)}40%{transform:translate(calc(var(--i)*-1.4px),0);clip-path:inset(30% 0 40% 0)}60%{transform:translate(calc(var(--i)*.8px),0);clip-path:inset(75% 0 5% 0)}80%{transform:translate(calc(var(--i)*-.6px),0);clip-path:inset(5% 0 80% 0)}100%{transform:translate(0);clip-path:inset(0 0 100% 0)}}@keyframes g2{0%{transform:translate(calc(var(--i)*1px),0);clip-path:inset(50% 0 30% 0)}20%{transform:translate(calc(var(--i)*-1px),0);clip-path:inset(5% 0 80% 0)}40%{transform:translate(calc(var(--i)*1.2px),0);clip-path:inset(70% 0 10% 0)}60%{transform:translate(calc(var(--i)*-1.4px),0);clip-path:inset(20% 0 55% 0)}80%{transform:translate(calc(var(--i)*.6px),0);clip-path:inset(45% 0 35% 0)}100%{transform:translate(0);clip-path:inset(0 0 100% 0)}}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}.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 gl=document.getElementById('gl'),is=document.getElementById('is'),calm=matchMedia('(prefers-reduced-motion:reduce)').matches;
function set(){gl.style.setProperty('--i',is.value);document.getElementById('iv').textContent=is.value+'px';}
function burst(){if(calm){gl.classList.add('st');setTimeout(()=>gl.classList.remove('st'),900);return;}gl.classList.remove('go');void gl.offsetWidth;gl.classList.add('go');}
['mouseenter','focus'].forEach(t=>gl.addEventListener(t,burst));document.getElementById('bt').addEventListener('click',burst);is.addEventListener('input',set);set();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>Glitch Text Slices — 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}
.gl{position:relative;display:grid;place-items:center;width:100%;height:110px;border-radius:12px;background:#0d0f14;color:#fff;overflow:hidden;font:900 52px/1 system-ui,'Arial Black',sans-serif;letter-spacing:.04em}.gl span,.gl::before,.gl::after{grid-area:1/1}.gl::before,.gl::after{content:attr(data-text);pointer-events:none;opacity:0}.gl::before{color:#00e5ff;mix-blend-mode:screen}.gl::after{color:#ff2d55;mix-blend-mode:screen}.gl.go::before{opacity:1;animation:g1 .6s steps(1) 1}.gl.go::after{opacity:1;animation:g2 .6s steps(1) 1}.gl.st::before{opacity:1;transform:translateX(calc(var(--i)*-.4px))}.gl.st::after{opacity:1;transform:translateX(calc(var(--i)*.4px))}@keyframes g1{0%{transform:translate(calc(var(--i)*-1px),0);clip-path:inset(10% 0 70% 0)}20%{transform:translate(calc(var(--i)*1px),0);clip-path:inset(60% 0 10% 0)}40%{transform:translate(calc(var(--i)*-1.4px),0);clip-path:inset(30% 0 40% 0)}60%{transform:translate(calc(var(--i)*.8px),0);clip-path:inset(75% 0 5% 0)}80%{transform:translate(calc(var(--i)*-.6px),0);clip-path:inset(5% 0 80% 0)}100%{transform:translate(0);clip-path:inset(0 0 100% 0)}}@keyframes g2{0%{transform:translate(calc(var(--i)*1px),0);clip-path:inset(50% 0 30% 0)}20%{transform:translate(calc(var(--i)*-1px),0);clip-path:inset(5% 0 80% 0)}40%{transform:translate(calc(var(--i)*1.2px),0);clip-path:inset(70% 0 10% 0)}60%{transform:translate(calc(var(--i)*-1.4px),0);clip-path:inset(20% 0 55% 0)}80%{transform:translate(calc(var(--i)*.6px),0);clip-path:inset(45% 0 35% 0)}100%{transform:translate(0);clip-path:inset(0 0 100% 0)}}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}.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"><button class="gl" id="gl" type="button" data-text="SIGNAL"><span>SIGNAL</span></button><div class="two"><label class="rw">Intensity <b id="iv">6px</b><input id="is" type="range" min="1" max="14" value="6"></label><button class="mini" id="bt" type="button">Glitch</button></div></div>
</div>
<script>
const gl=document.getElementById('gl'),is=document.getElementById('is'),calm=matchMedia('(prefers-reduced-motion:reduce)').matches;
function set(){gl.style.setProperty('--i',is.value);document.getElementById('iv').textContent=is.value+'px';}
function burst(){if(calm){gl.classList.add('st');setTimeout(()=>gl.classList.remove('st'),900);return;}gl.classList.remove('go');void gl.offsetWidth;gl.classList.add('go');}
['mouseenter','focus'].forEach(t=>gl.addEventListener(t,burst));document.getElementById('bt').addEventListener('click',burst);is.addEventListener('input',set);set();
</script>
</body></html>