JSFiddle - React, Tailwind, and code Playground
HTML
<div class="tab">
<button>Click Me</button>
</div>
CSS
.tab button {
background-color: yellow;
}
/* Create an active/current tablink class */
.tab button.active {
background-color: red;
}
JavaScript
document.querySelector('button').addEventListener('click', changeColor);
function changeColor(evt){
evt.currentTarget.className += " active";
}