AI CSS Animations

Random Flicker Text Effect

Individual letters drop out and stutter back at what looks like random, like a failing display. Each letter runs the same keyframe at its own duration and offset, so the pattern never lines up.

Also known as: flickering letters css, unstable text effect, horror flicker text.

UNSTABLE

HTML

<div class="txt-random-flicker-text" aria-label="UNSTABLE"><span style="--i: 0; --d: 2.3s; --t: -0.4s">U</span><span style="--i: 1; --d: 1.7s; --t: -1.1s">N</span><span style="--i: 2; --d: 3.1s; --t: -0.2s">S</span><span style="--i: 3; --d: 1.9s; --t: -1.6s">T</span><span style="--i: 4; --d: 2.9s; --t: -0.9s">A</span><span style="--i: 5; --d: 1.3s; --t: -0.5s">B</span><span style="--i: 6; --d: 2.6s; --t: -2.2s">L</span><span style="--i: 7; --d: 3.7s; --t: -1.3s">E</span></div>

CSS

.txt-random-flicker-text {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.08em;
  color: var(--c);}
.txt-random-flicker-text span {
  display: inline-block;
  animation: txt-random-flicker-text-drop var(--d) steps(1, end) var(--t) infinite;
}
@keyframes txt-random-flicker-text-drop {
  0%, 10%, 55%, 100% { opacity: 1; transform: none; }
  2% { opacity: 0.1; }
  4% { opacity: 1; transform: translateX(0.03em); }
  6% { opacity: 0; }
  8% { opacity: 0.7; transform: translateX(-0.02em); }
  51% { opacity: 0.2; }
  53% { opacity: 1; transform: translateY(0.02em); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-random-flicker-text, .txt-random-flicker-text *, .txt-random-flicker-text::before, .txt-random-flicker-text::after, .txt-random-flicker-text *::before, .txt-random-flicker-text *::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