Generate customizable progress bars with animations
<div class="progress-container">
<div class="progress-bar" role="progressbar" aria-valuenow="65" aria-valuemin="0" aria-valuemax="100">
<span class="progress-label">65%</span>
</div>
</div>.progress-container {
width: 100%;
height: 24px;
background-color: #E5E7EB;
border-radius: 8px;
overflow: hidden;
position: relative;
}
.progress-bar {
height: 100%;
width: 0%;
background: #3B82F6;
transition: width 1.5s ease-out;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
.progress-label {
color: white;
font-weight: 600;
font-size: 14px;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
// Animate progress bar on load
window.addEventListener('DOMContentLoaded', () => {
const progressBar = document.querySelector('.progress-bar');
if (progressBar) {
// Trigger reflow
progressBar.offsetWidth;
progressBar.style.width = '65%';
}
});
// Function to update progress
function updateProgress(value) {
const progressBar = document.querySelector('.progress-bar');
const label = document.querySelector('.progress-label');
if (progressBar) {
progressBar.style.width = value + '%';
progressBar.setAttribute('aria-valuenow', value);
}
if (label) {
label.textContent = value + '%';
}
}Help others discover this tool!