One word in a sentence cycles through alternatives, each sliding up to replace the last. The list ends with a repeat of the first word so the loop closes without a jump.
Also known as: word carousel, changing text animation, text slider.
<div class="txt-word-rotate">We build
<span class="txt-word-rotate-words">
<span>apps.</span><span>brands.</span><span>websites.</span><span>apps.</span>
</span>
</div>.txt-word-rotate {
--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;
gap: 0.3em;
color: #1f2937;}
.txt-word-rotate-words {
display: inline-block;
height: 1.2em;
overflow: hidden;
color: var(--c);
}
.txt-word-rotate-words span {
display: block;
animation: txt-word-rotate-cycle 6s cubic-bezier(0.8, 0, 0.2, 1) infinite;
}
@keyframes txt-word-rotate-cycle {
0%, 25% { transform: translateY(0); }
33%, 58% { transform: translateY(-1.2em); }
66%, 91% { transform: translateY(-2.4em); }
100% { transform: translateY(-3.6em); }
}
@media (prefers-reduced-motion: reduce) {
.txt-word-rotate, .txt-word-rotate *, .txt-word-rotate::before, .txt-word-rotate::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.