Each letter sits in its own little drum and rolls to the next word a beat after its neighbor, like an odometer turning over. Words need the same length; a monospace font keeps the drums even.
Also known as: rolling letters text, mechanical counter words, slot letters animation.
<div class="txt-odometer-word-roll" aria-label="Be bold, kind, free, wild">Be
<span class="txt-odometer-word-roll-word" aria-hidden="true">
<span><span style="--i: 0"><span>b</span><span>k</span><span>f</span><span>w</span><span>b</span></span></span>
<span><span style="--i: 1"><span>o</span><span>i</span><span>r</span><span>i</span><span>o</span></span></span>
<span><span style="--i: 2"><span>l</span><span>n</span><span>e</span><span>l</span><span>l</span></span></span>
<span><span style="--i: 3"><span>d</span><span>d</span><span>e</span><span>d</span><span>d</span></span></span>
</span>
</div>.txt-odometer-word-roll {
--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: center;
gap: 0.3em;
white-space: nowrap;}
.txt-odometer-word-roll-word {
display: inline-flex;
gap: 0.06em;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
color: var(--c);
}
/* one drum per letter */
.txt-odometer-word-roll-word > span {
height: 1.2em;
padding: 0 0.08em;
overflow: hidden;
border-radius: 0.12em;
background: color-mix(in srgb, var(--c) 12%, transparent);
}
.txt-odometer-word-roll-word > span > span {
display: flex;
flex-direction: column;
/* 4 words x 1.8s = 7.2s; each drum starts 70ms after the one on its left */
animation: txt-odometer-word-roll-turn 7.2s cubic-bezier(0.45, 0, 0.25, 1.3) infinite;
animation-delay: calc(var(--i) * 70ms);
}
.txt-odometer-word-roll-word > span > span > span {
height: 1.2em;
}
@keyframes txt-odometer-word-roll-turn {
0%, 17.36% { transform: translateY(0); }
25%, 42.36% { transform: translateY(-1.2em); }
50%, 67.36% { transform: translateY(-2.4em); }
75%, 92.36% { transform: translateY(-3.6em); }
100% { transform: translateY(-4.8em); }
}
@media (prefers-reduced-motion: reduce) {
.txt-odometer-word-roll, .txt-odometer-word-roll *, .txt-odometer-word-roll::before, .txt-odometer-word-roll::after, .txt-odometer-word-roll *::before, .txt-odometer-word-roll *::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.