A gradient flows through the letters, clipped to the text. The second and third colors are mixed from your accent, so changing one variable retints the whole gradient.
Also known as: gradient text css, moving gradient text, color shift text.
<div class="txt-gradient">Beautiful gradients</div>
.txt-gradient {
--c: var(--txt-color, #3b82f6);
font-size: var(--txt-size, 32px);
font-family: system-ui, sans-serif;
font-weight: 700;
line-height: 1.2;
background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 40%, #a855f7), color-mix(in srgb, var(--c) 40%, #ec4899), var(--c));
background-size: 300% 100%;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
animation: txt-gradient-flow 4s linear infinite;}
@keyframes txt-gradient-flow {
to { background-position: 300% 0; }
}
@media (prefers-reduced-motion: reduce) {
.txt-gradient, .txt-gradient *, .txt-gradient::before, .txt-gradient::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}The same effect using Tailwind utility classes. No custom CSS or config needed.
<div class="bg-gradient-to-r from-blue-500 via-purple-500 to-pink-500 bg-clip-text text-4xl font-bold text-transparent"> Beautiful gradients </div>
--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.