Each letter is wound down onto a spring, released, and bobs above and below its resting line with shrinking swings. The squash and stretch rides along with the motion, pinned to the baseline.
Also known as: spring animation text, elastic letters, boing letters css.
<div class="txt-springy-text" aria-label="Spring sale"><span aria-hidden="true"><span style="--i: 0">S</span><span style="--i: 1">p</span><span style="--i: 2">r</span><span style="--i: 3">i</span><span style="--i: 4">n</span><span style="--i: 5">g</span><span style="--i: 6"> </span><span style="--i: 7">s</span><span style="--i: 8">a</span><span style="--i: 9">l</span><span style="--i: 10">e</span></span></div>
.txt-springy-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;
color: var(--c);}
.txt-springy-text span span {
display: inline-block;
transform-origin: 50% 100%;
animation: txt-springy-text-boing 2.4s ease-in-out infinite;
animation-delay: calc(var(--i) * 0.05s);
}
@keyframes txt-springy-text-boing {
0%, 62%, 100% { transform: translateY(0) scale(1, 1); }
/* wind down slowly, release fast */
10% { transform: translateY(0.1em) scale(1.12, 0.84); }
16% { transform: translateY(-0.5em) scale(0.9, 1.14); }
24% { transform: translateY(0.16em) scale(1.06, 0.92); }
32% { transform: translateY(-0.22em) scale(0.97, 1.04); }
40% { transform: translateY(0.07em) scale(1.02, 0.98); }
48% { transform: translateY(-0.05em) scale(1, 1); }
55% { transform: translateY(0.02em) scale(1, 1); }
}
@media (prefers-reduced-motion: reduce) {
.txt-springy-text, .txt-springy-text *, .txt-springy-text::before, .txt-springy-text::after, .txt-springy-text *::before, .txt-springy-text *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--txt-color on the element or a parent.
Currently previewing #3b82f6.--txt-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 40px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.