Master Bootstrap From Scratch

Clear, interactive, and structured Bootstrap lessons designed for beginners and developers.

Bootstrap Progress Bars

Learn how to create progress bars in Bootstrap to display the completion status of tasks, downloads, uploads, and projects.

What are Progress Bars?

A progress bar is a visual component that shows how much of a task has been completed.

For example, if a task is 60% complete, the progress bar displays 60% of its total width as filled.

Simple Example: A course completion progress bar showing 75% completion.

Why Use Progress Bars?

Progress bars help users understand the status of an ongoing task.

  • Display course completion percentages.
  • Show file upload or download progress.
  • Track project completion.
  • Display the progress of a form or installation.

Basic Progress Bar

Bootstrap uses the .progress class as the progress bar container and .progress-bar for the filled portion.

Example:
60%
Code:
<div class="progress"
     role="progressbar"
     aria-valuenow="60"
     aria-valuemin="0"
     aria-valuemax="100">

    <div class="progress-bar" style="width: 60%">
        60%
    </div>

</div>
Simple Explanation: The width: 60% property fills 60% of the progress bar. The remaining 40% stays unfilled.

Progress Bar Colors

Bootstrap provides background utility classes to change the color of a progress bar.

Example:

Primary

70%

Success

80%

Warning

50%

Danger

30%
<div class="progress">
    <div class="progress-bar bg-primary"
         style="width: 70%">
        70%
    </div>
</div>

<div class="progress">
    <div class="progress-bar bg-success"
         style="width: 80%">
        80%
    </div>
</div>

<div class="progress">
    <div class="progress-bar bg-danger"
         style="width: 30%">
        30%
    </div>
</div>
Simple Explanation: bg-primary, bg-success, bg-warning, and bg-danger apply different colors to the filled bar.

Progress Bar Height

You can change the height of a progress bar using CSS.

Example:

Small Height

Default Height

Large Height

60%
<div class="progress" style="height: 30px;">

    <div class="progress-bar bg-success"
         style="width: 60%">
        60%
    </div>

</div>
Simple Explanation: The height property changes the total height of the progress bar.

Progress Bar with Label

You can display the completion percentage inside the progress bar.

Example:
85% Complete
<div class="progress">

    <div class="progress-bar bg-success"
         style="width: 85%">
        85% Complete
    </div>

</div>
Simple Explanation: The text inside the progress bar tells users how much of the task is complete.

Striped Progress Bars

Add the .progress-bar-striped class to display diagonal stripes on the progress bar.

Example:
65%
<div class="progress">

    <div class="progress-bar progress-bar-striped bg-primary"
         style="width: 65%">
        65%
    </div>

</div>
Remember: The .progress-bar-striped class adds a striped design. It does not automatically animate the progress.

Animated Progress Bars

Add .progress-bar-animated along with .progress-bar-striped to animate the stripes.

Example:
75%
<div class="progress">

    <div class="progress-bar progress-bar-striped progress-bar-animated bg-success"
         style="width: 75%">
        75%
    </div>

</div>
Simple Explanation: The stripes move continuously to create an animated effect. The percentage does not increase automatically.

Multiple Progress Bars

You can place multiple progress bars inside one progress container to show different parts of a task.

Example:
40%
30%
30%
<div class="progress">

    <div class="progress-bar bg-success"
         style="width: 40%">
        40%
    </div>

    <div class="progress-bar bg-info"
         style="width: 30%">
        30%
    </div>

    <div class="progress-bar bg-warning"
         style="width: 30%">
        30%
    </div>

</div>
Simple Explanation: The three sections occupy 40%, 30%, and 30% of the container. Together, they fill 100% of the progress bar.

Real-World Example

A training institute can use progress bars to display the completion status of different courses.

HTML and CSS 100%
Completed
JavaScript 70%
70%
Bootstrap 40%
40%
Simple Explanation: Students can see how much of each course they have completed and how much work remains.

Important Bootstrap Progress Bar Classes

Class Purpose
.progress Creates the progress bar container.
.progress-bar Creates the filled progress section.
.bg-success Applies a green background.
.bg-primary Applies the primary background color.
.progress-bar-striped Adds diagonal stripes.
.progress-bar-animated Animates the striped effect.
style="width: 60%" Sets the filled portion to 60%.

Common Mistakes

  • Forgetting the .progress container.
  • Forgetting the .progress-bar class.
  • Using an incorrect width percentage.
  • Assuming an animated progress bar automatically increases its percentage.
  • Forgetting accessibility attributes such as aria-valuenow, aria-valuemin, and aria-valuemax.

Summary

Bootstrap Progress Bars visually display the completion status of a task.

  • .progress creates the container.
  • .progress-bar creates the filled section.
  • The CSS width property sets the percentage.
  • Background classes change the progress bar color.
  • .progress-bar-striped adds stripes.
  • .progress-bar-animated animates the stripes.
  • JavaScript or application logic is needed to update progress dynamically.