AI CSS Animations

Reverse Stagger Text Animation

Letters slide in from the left starting with the last one, so the word builds from its end back to its start and each letter bumps into its neighbour. The delay counts down from --n.

Also known as: last letter first animation, right to left letter reveal, reverse text animation css.

Rewind

HTML

<div class="txt-reverse-letter-stagger" aria-label="Rewind"><span style="--i: 0">R</span><span style="--i: 1">e</span><span style="--i: 2">w</span><span style="--i: 3">i</span><span style="--i: 4">n</span><span style="--i: 5">d</span></div>

CSS

.txt-reverse-letter-stagger {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  /* --n = number of letters */
  --n: 6;
  color: var(--c);
  white-space: nowrap;}
.txt-reverse-letter-stagger span {
  display: inline-block;
  animation: txt-reverse-letter-stagger-in 0.6s cubic-bezier(0.25, 0.9, 0.3, 1.25) calc((var(--n) - 1 - var(--i)) * 90ms) both;
}
@keyframes txt-reverse-letter-stagger-in {
  0%   { opacity: 0; transform: translateX(-1.4em) skewX(15deg); }
  40%  { opacity: 1; }
  100% { opacity: 1; transform: translateX(0) skewX(0); }
}

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