How to build a progress bar with Tailwind CSS
We’re gonna build this progress bar using Tailwind CSS:

Here’s the code I used to create this bar, and I’ll explain it below.
<div
class="h-24 bg-cyan-50 rounded-xl border-4 border-cyan-800 overflow-hidden"
>
<div class="bg-cyan-500 h-full" style="width: 87%" id="progress-bar"></div>
</div>
- The outer
divhas a defined height and will take up the full width of the page by default. - I gave the outer
divrounded corners and a border. Its background color is the light color you see on the rightmost end of the bar (the unfilled part). - The inside
divhas a darker background color, in this casebg-cyan-500. The insidedivis the filled part of the progress bar. - The inside
divhash-full, which makes its height the same as the outerdiv. - I use a
styleattribute to set the width of the bar to a certain percentage. In practice, you could use JavaScript to change the width of the bar:
document.getElementById("bar").style.width = `${(11 / 12) * 100}%`;
// Multiplies the decimal by 100 to get a percentage.
Changing the progress bar’s progress using JavaScript.
You can try out this code example on Tailwind Play.