The classic RGB-split glitch: two offset copies of the text in cyan and magenta flicker through random clip-path slices. The copies read from a data attribute, so the markup is one element.
Also known as: glitch effect css, distortion text, cyberpunk text.
<div class="txt-glitch" data-text="GLITCH">GLITCH</div>
.txt-glitch {
--c: var(--txt-color, #3b82f6);
font-size: var(--txt-size, 32px);
font-family: system-ui, sans-serif;
font-weight: 700;
line-height: 1.2;
position: relative;
color: var(--c);
letter-spacing: 0.05em;}
.txt-glitch::before,
.txt-glitch::after {
content: attr(data-text);
position: absolute;
inset: 0;
overflow: hidden;
}
.txt-glitch::before {
left: 2px;
text-shadow: -2px 0 #ff00c8;
animation: txt-glitch-a 2s infinite linear alternate-reverse;
}
.txt-glitch::after {
left: -2px;
text-shadow: 2px 0 #00fff9;
animation: txt-glitch-b 3s infinite linear alternate-reverse;
}
@keyframes txt-glitch-a {
0% { clip-path: inset(20% 0 60% 0); }
20% { clip-path: inset(70% 0 10% 0); }
40% { clip-path: inset(10% 0 80% 0); }
60% { clip-path: inset(50% 0 30% 0); }
80% { clip-path: inset(80% 0 5% 0); }
100% { clip-path: inset(30% 0 50% 0); }
}
@keyframes txt-glitch-b {
0% { clip-path: inset(60% 0 20% 0); }
20% { clip-path: inset(10% 0 70% 0); }
40% { clip-path: inset(80% 0 10% 0); }
60% { clip-path: inset(30% 0 50% 0); }
80% { clip-path: inset(5% 0 80% 0); }
100% { clip-path: inset(50% 0 30% 0); }
}
@media (prefers-reduced-motion: reduce) {
.txt-glitch, .txt-glitch *, .txt-glitch::before, .txt-glitch::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--txt-color on the element or a parent.
Currently previewing #3b82f6.--txt-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 40px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.