JSFiddle - React, Tailwind, and code Playground
HTML
<div id='colors'></div>
JavaScript
function RainBowColor(length, maxLength)
{
var i = (length * 255 / maxLength);
var r = Math.round(Math.sin(0.024 * i + 0) * 127 + 128);
var g = Math.round(Math.sin(0.024 * i + 2) * 127 + 128);
var b = Math.round(Math.sin(0.024 * i + 4) * 127 + 128);
return 'rgb(' + r + ',' + g + ',' + b + ')';
}
for (var i = 0; i <= 255; i++) {
$('<span>█</span>').css({
color: RainBowColor(i, 255)
}).appendTo('#colors');
}