JSFiddle - React, Tailwind, and code Playground
HTML
<div id="test" onclick="animate('test', 75);">0%</div>
CSS
#test {
height: 25px;
width: 25px;
background: green;
transition: width 3s ease;
cursor: pointer;
}
JavaScript
function animate(elem, num) {
var test = document.getElementById(elem);
var width = test.offsetWidth;
if(width == 25) {
test.style.width = num + '%';
} else {
test.style.width = '25px';
}
}