JSFiddle - React, Tailwind, and code Playground

HTML

<a id="setcolor" class="colors" href="#" role="button" data-value="mycolor">Choose color</a>

JavaScript

window.onload = function(){
document.getElementById("setcolor").click();
}

var color = "red";
var setcolor = document.getElementById("setcolor");
setcolor.dataset.value = color;