JSFiddle - React, Tailwind, and code Playground

JavaScript

function hexToRgb(hex) {
    return {
        r: parseInt(hex.substring(1, 3), 16),
        g: parseInt(hex.substring(3, 5), 16),
        b: parseInt(hex.substring(5, 7), 16)
    };
}

function blendColors(colorA, colorB, weight) {
    return {
        r: Math.floor(colorA.r * (1 - weight) + colorB.r * weight),
        g: Math.floor(colorA.g * (1 - weight) + colorB.g * weight),
        b: Math.floor(colorA.b * (1 - weight) + colorB.b * weight)
    };
}

var w = 0;
var d = 0.05;

setInterval(function() {
    var blendedColor = blendColors(hexToRgb('#666666'), hexToRgb('#0000ff'), w);
    document.body.style.backgroundColor = 'rgb(' + blendedColor.r + ', ' + blendedColor.g + ', ' + blendedColor.b + ')';
    
    w += d;
    
    if(w < 0 || w > 1) {
        d = -d;
        w += d;
    }
}, 33);