AI CSS Animations

Cyberpunk Glitch Text

A yellow, corner-cut label in the cyberpunk UI style that jolts every few seconds while inverted slices of it tear sideways. The yellow is fixed; the slices use your accent color.

Also known as: cyberpunk text effect css, cyberpunk ui label, glitch banner text.

BREACH

HTML

<div class="txt-cyberpunk-glitch" data-text="BREACH">BREACH</div>

CSS

.txt-cyberpunk-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;
  display: inline-block;
  isolation: isolate;
  padding: 0.14em 0.85em 0.14em 0.6em;
  color: #0b0b0f;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-shadow: -0.05em 0 var(--c);
  animation: txt-cyberpunk-glitch-jolt 2.8s steps(1, end) infinite;}
.txt-cyberpunk-glitch::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #fcee0a;
  clip-path: polygon(0 0, calc(100% - 0.55em) 0, 100% 0.55em, 100% 100%, 0.4em 100%, 0 calc(100% - 0.4em));
}
.txt-cyberpunk-glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  padding: inherit;
  background: var(--c);
  color: #fcee0a;
  text-shadow: none;
  clip-path: inset(0 0 100% 0);
  animation: txt-cyberpunk-glitch-slice 2.8s steps(1, end) infinite;
}
@keyframes txt-cyberpunk-glitch-slice {
  0%, 58%, 69%, 76%, 100% { clip-path: inset(0 0 100% 0); transform: none; }
  60% { clip-path: inset(18% 0 56% 0); transform: translateX(-0.25em); }
  63% { clip-path: inset(62% 0 12% 0); transform: translateX(0.18em); }
  66% { clip-path: inset(36% 0 40% 0); transform: translateX(-0.12em); }
  72% { clip-path: inset(72% 0 6% 0); transform: translateX(0.3em); }
}
@keyframes txt-cyberpunk-glitch-jolt {
  0%, 58%, 69%, 76%, 100% { transform: none; }
  60% { transform: translateX(0.05em); }
  63% { transform: translateX(-0.06em) skewX(-6deg); }
  72% { transform: translateX(0.04em); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-cyberpunk-glitch, .txt-cyberpunk-glitch *, .txt-cyberpunk-glitch::before, .txt-cyberpunk-glitch::after, .txt-cyberpunk-glitch *::before, .txt-cyberpunk-glitch *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar text animations