AI CSS Animations

Words Pop Out One by One

Each word of the line springs up from nothing with a tilt, overshoots, wobbles and settles, and the last lands on an accent pill. Hand-tuned keyframes give a real spring rather than one bouncy curve.

Also known as: words popping out animation, word pop in css, spring text animation, pop up text animation.

Make every word count.

HTML

<div class="txt-words-spring-pop"><span style="--i: 0">Make</span> <span style="--i: 1">every</span> <span style="--i: 2">word</span> <span class="txt-words-spring-pop-hit" style="--i: 3">count.</span></div>

CSS

.txt-words-spring-pop {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 1.3);
  font-family: system-ui, sans-serif;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: -0.02em;}
.txt-words-spring-pop span {
  display: inline-block;
  transform-origin: 50% 90%;
  animation: txt-words-spring-pop-pop 4.2s infinite backwards;
  animation-delay: calc(var(--i) * 0.16s);
}
.txt-words-spring-pop-hit {
  padding: 0 0.16em 0.04em;
  border-radius: 0.24em;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 22%, transparent);
}
@keyframes txt-words-spring-pop-pop {
  0%   { opacity: 0; transform: translateY(0.45em) scale(0.2) rotate(-12deg); animation-timing-function: cubic-bezier(0.2, 0.9, 0.35, 1); }
  6%   { opacity: 1; transform: translateY(-0.1em) scale(1.14) rotate(4deg); animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
  10%  { transform: translateY(0.03em) scale(0.95) rotate(-1.5deg); animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
  14%  { transform: translateY(-0.01em) scale(1.02) rotate(0.5deg); animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
  18%, 76% { opacity: 1; transform: none; filter: blur(0); animation-timing-function: cubic-bezier(0.5, 0, 0.75, 0); }
  83%, 100% { opacity: 0; transform: translateY(-0.25em) scale(0.92); filter: blur(0.04em); }
}
@media (prefers-reduced-motion: reduce) {
  .txt-words-spring-pop span { animation: none; }
}

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