A gradient pours into faint letters from the left, holds, then drains out to the right, over and over. Half of an oversized layer is transparent, so one position animation does both halves.
Also known as: text fill loading animation, loading text css, progress fill text.
<div class="txt-gradient-loading-text">Loading</div>
.txt-gradient-loading-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;
font-weight: 800;
letter-spacing: 0.04em;
background:
linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 45%, #a855f7) 36%, color-mix(in srgb, var(--c) 40%, #ec4899) 50%, transparent 50%) 0 0 / 200% 100% no-repeat,
color-mix(in srgb, var(--c) 22%, transparent);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
animation: txt-gradient-loading-text-fill 2.6s cubic-bezier(0.65, 0, 0.35, 1) infinite;}
@keyframes txt-gradient-loading-text-fill {
0% { background-position: 100% 0; }
50%, 62% { background-position: 0% 0; }
100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
.txt-gradient-loading-text, .txt-gradient-loading-text *, .txt-gradient-loading-text::before, .txt-gradient-loading-text::after, .txt-gradient-loading-text *::before, .txt-gradient-loading-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.