JSFiddle - React, Tailwind, and code Playground
HTML
<progress value="0" max="100"></progress>
<span id="current-progress">0%</span>
CSS
progress {
background-color: #333;
border: 0;
height: 18px;
}
progress::-webkit-progress-bar {
background-color: #333;
}
progress::-webkit-progress-value {
background-color: #0378a8;
}
progress::-moz-progress-bar {
background-color: #0378a8;
}
#current-progress {
display: inline-block;
font-family: sans-serif;
}
JavaScript
var progress = document.getElementsByTagName('progress')[0],
currentProgress = document.getElementById('current-progress');
var counter = setInterval(function() {
var current = progress.value + 1;
if (current === progress.max + 1) {
clearInterval(counter);
return;
}
progress.value = current;
currentProgress.innerHTML = current + '%';
}, 2000 / progress.max);