Typography · 11 of 33
Color Chase
Gradient follows your cursor
<div class="color-chase-wrapper">
<p class="color-chase-headline" id="colorChaseHeadline">Chase the Light</p>
</div>
.color-chase-headline {
font-size: 3.5rem;
font-weight: 600;
background: linear-gradient(90deg,
#f0f0f5 0%, #f0f0f5 35%, #7c5cff 50%, #f0f0f5 65%, #f0f0f5 100%);
background-size: 200% 100%;
background-position: 50% 0;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
transition: background-position 0.08s ease-out;
}
var headline = document.getElementById('colorChaseHeadline');
var wrapper = document.querySelector('.color-chase-wrapper');
wrapper.addEventListener('mousemove', function (e) {
var rect = wrapper.getBoundingClientRect();
var x = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
headline.style.backgroundPosition = ((1 - x) * 100) + '% 0';
});