AI CSS Animations

Blur Rotating Text

The last word of a headline dissolves into a soft blur while the next one comes into focus, like a camera pulling focus. All words share one grid cell, so the line never shifts.

Also known as: blur text transition, fade blur word swap, changing words animation.

Built for teams speed scale you

HTML

<div class="txt-blur-rotating-text">Built for
  <span class="txt-blur-rotating-text-words">
    <span style="--i: 0">teams</span>
    <span style="--i: 1">speed</span>
    <span style="--i: 2">scale</span>
    <span style="--i: 3">you</span>
  </span>
</div>

CSS

.txt-blur-rotating-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;
  display: flex;
  align-items: baseline;
  gap: 0.28em;
  white-space: nowrap;}
.txt-blur-rotating-text-words {
  display: inline-grid;
  color: var(--c);
}
.txt-blur-rotating-text-words span {
  grid-area: 1 / 1;
  justify-self: start;
  transform-origin: 0 60%;
  /* 4 words x 2s each = 8s */
  animation: txt-blur-rotating-text-focus 8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  animation-delay: calc(var(--i) * 2s - 8s);
}
.txt-blur-rotating-text-words span:not(:first-child) {
  opacity: 0;
}
@keyframes txt-blur-rotating-text-focus {
  0%, 16.25% { opacity: 1; filter: blur(0); transform: scale(1); }
  25%     { opacity: 0; filter: blur(0.22em); transform: scale(1.08); }
  91.25%  { opacity: 0; filter: blur(0.22em); transform: scale(0.92); }
  100%    { opacity: 1; filter: blur(0); transform: scale(1); }
}

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