Bootstrap 5 Progress Bars
A progress bar shows how far along something is: an upload, a course, a profile setup. Bootstrap builds it from two nested elements: an outer .progress track and an inner .progress-bar whose width sets the amount.
Basic structure
The outer element carries the accessibility information: role="progressbar" and the aria-valuenow, aria-valuemin and aria-valuemax attributes. The inner bar's width is set with an inline style or a width utility (w-25, w-50, w-75, w-100).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="progress mb-3" role="progressbar" aria-label="Upload" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar" style="width: 25%"></div>
</div>
<div class="progress mb-3" role="progressbar" aria-label="Course" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar" style="width: 60%">60%</div>
</div>
<div class="progress" role="progressbar" aria-label="Done" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar w-100">Complete</div>
</div>
</body>
</html>Note: Bootstrap 5.3 moved
roleand thearia-*attributes from the inner bar to the outer.progresselement. Older tutorials put them on.progress-bar; both render, but 5.3's structure is the recommended one.
Height, colours, stripes and animation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="progress mb-2" role="progressbar" aria-label="Thin" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="height: 4px">
<div class="progress-bar bg-info" style="width: 40%"></div>
</div>
<div class="progress mb-2" role="progressbar" aria-label="Success" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="height: 24px">
<div class="progress-bar bg-success" style="width: 70%">70%</div>
</div>
<div class="progress mb-2" role="progressbar" aria-label="Warning" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar text-bg-warning" style="width: 50%">50%</div>
</div>
<div class="progress mb-2" role="progressbar" aria-label="Striped" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar progress-bar-striped bg-danger" style="width: 80%"></div>
</div>
<div class="progress" role="progressbar" aria-label="Animated" aria-valuenow="65" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width: 65%"></div>
</div>
</body>
</html>Set the height on the outer .progress; the inner bar follows. Use .text-bg-warning for light colours so the label stays readable.
Multiple bars (stacked)
To show several segments in one bar (e.g. disk usage by type), wrap separate .progress elements in a .progress-stacked container. Each segment's width goes on its outer .progress.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<p class="mb-1 small">Storage: 📷 photos, 🎵 music, 📄 documents</p>
<div class="progress-stacked">
<div class="progress" role="progressbar" aria-label="Photos" aria-valuenow="35" aria-valuemin="0" aria-valuemax="100" style="width: 35%">
<div class="progress-bar">📷 35%</div>
</div>
<div class="progress" role="progressbar" aria-label="Music" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 20%">
<div class="progress-bar bg-success">🎵 20%</div>
</div>
<div class="progress" role="progressbar" aria-label="Documents" aria-valuenow="15" aria-valuemin="0" aria-valuemax="100" style="width: 15%">
<div class="progress-bar bg-warning">📄</div>
</div>
</div>
</body>
</html>Updating progress with JavaScript
Change the inner bar's width — the CSS transition animates it — and keep aria-valuenow in sync.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="progress mb-3" role="progressbar" aria-label="Task" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" id="track">
<div class="progress-bar" id="bar" style="width: 0%">0%</div>
</div>
<button class="btn btn-primary" onclick="step()">+20%</button>
<script>
let value = 0;
function step() {
value = value >= 100 ? 0 : value + 20;
const bar = document.getElementById('bar');
bar.style.width = value + '%';
bar.textContent = value + '%';
document.getElementById('track').setAttribute('aria-valuenow', value);
console.log('progress', value);
}
</script>
</body>
</html>Class reference
| Class | Purpose |
|---|---|
.progress |
Outer track (gets role and aria-*) |
.progress-bar |
Filled part; width = progress |
.bg-{color} / .text-bg-{color} |
Bar colour |
.progress-bar-striped |
Diagonal stripes |
.progress-bar-animated |
Moving stripes (use with striped) |
.progress-stacked |
Container for multi-segment bars (5.3) |
Tip: If you don't know how long something will take, a progress bar is the wrong tool — use a spinner instead (next lesson).
Test yourself
What determines how full a Bootstrap progress bar looks?
- aria-valuenow
- The width of .progress-bar
- The height of .progress
- A data-bs-value attribute
Which classes give a bar moving stripes?
- .progress-bar-striped .progress-bar-animated
- .progress-animated
- .striped .moving
- .progress-bar-animated only
Where do you set the height of a progress bar?
- On the inner .progress-bar
- On the outer .progress
- On the body
- With .progress-lg