Letter by letter, the old word tumbles out of the headline and the next one drops in from above with a small bounce. Every letter carries its index, and every word its slot, in custom properties.
Also known as: letter by letter word swap, letters drop text rotator, per letter word change.
<div class="txt-falling-letters-rotating-text" aria-label="Made for makers, dreamers and doers">Made for
<span class="txt-falling-letters-rotating-text-words" aria-hidden="true">
<span style="--w: 0"><span style="--i: 0">m</span><span style="--i: 1">a</span><span style="--i: 2">k</span><span style="--i: 3">e</span><span style="--i: 4">r</span><span style="--i: 5">s</span></span>
<span style="--w: 1"><span style="--i: 0">d</span><span style="--i: 1">r</span><span style="--i: 2">e</span><span style="--i: 3">a</span><span style="--i: 4">m</span><span style="--i: 5">e</span><span style="--i: 6">r</span><span style="--i: 7">s</span></span>
<span style="--w: 2"><span style="--i: 0">d</span><span style="--i: 1">o</span><span style="--i: 2">e</span><span style="--i: 3">r</span><span style="--i: 4">s</span></span>
</span>
</div>.txt-falling-letters-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-falling-letters-rotating-text-words {
display: inline-grid;
color: var(--c);
}
.txt-falling-letters-rotating-text-words > span {
grid-area: 1 / 1;
display: flex;
}
.txt-falling-letters-rotating-text-words span span {
display: inline-block;
/* 3 words x 2.2s = 6.6s, plus 40ms per letter */
animation: txt-falling-letters-rotating-text-drop 6.6s infinite;
animation-delay: calc(var(--i) * 40ms + var(--w) * 2.2s - 7.3s);
}
.txt-falling-letters-rotating-text-words > span:not(:first-child) span {
opacity: 0;
}
@keyframes txt-falling-letters-rotating-text-drop {
0% {
opacity: 0; transform: translateY(-0.6em);
animation-timing-function: cubic-bezier(0.3, 1.5, 0.6, 1);
}
6.06% { opacity: 1; transform: translateY(0); }
28.03% {
opacity: 1; transform: translateY(0) rotate(0);
animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
}
33.33% { opacity: 0; transform: translateY(0.7em) rotate(calc(var(--i) * 9deg - 25deg)); }
100% { opacity: 0; transform: translateY(-0.6em); }
}
@media (prefers-reduced-motion: reduce) {
.txt-falling-letters-rotating-text, .txt-falling-letters-rotating-text *, .txt-falling-letters-rotating-text::before, .txt-falling-letters-rotating-text::after, .txt-falling-letters-rotating-text *::before, .txt-falling-letters-rotating-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.