Gradient-filled text whose colors swing around to the other side on hover. The gradient angle is a registered @property, so the browser can transition it like any number.
Also known as: gradient text on hover, rotating gradient text, color shift text.
<div class="hfx-text-gradient-spin">Vibrant</div>
@property --hfx-text-gradient-spin-angle {
syntax: "<angle>";
inherits: false;
initial-value: 90deg;
}
.hfx-text-gradient-spin {
--c: var(--hfx-color, #3b82f6);
font-size: calc(var(--hfx-size, 16px) * 2.5);
font-family: system-ui, sans-serif;
font-weight: 800;
line-height: 1.15;
cursor: default;
display: inline-block;
font-weight: 900;
-webkit-text-fill-color: transparent;
background: linear-gradient(
var(--hfx-text-gradient-spin-angle),
var(--c),
color-mix(in srgb, var(--c) 45%, #ec4899),
color-mix(in srgb, var(--c) 30%, #f59e0b)
);
-webkit-background-clip: text;
background-clip: text;
transition: --hfx-text-gradient-spin-angle 0.8s cubic-bezier(0.65, 0, 0.35, 1);}
.hfx-text-gradient-spin:hover { --hfx-text-gradient-spin-angle: 270deg; }
@media (prefers-reduced-motion: reduce) {
.hfx-text-gradient-spin, .hfx-text-gradient-spin *, .hfx-text-gradient-spin::before, .hfx-text-gradient-spin::after, .hfx-text-gradient-spin *::before, .hfx-text-gradient-spin *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--hfx-color on the element or a parent.
Currently previewing #3b82f6.--hfx-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.