The Bootstrap progress bar is the easiest way of creating a progress bar using its classes. You can create different types of Bootstrap progress bar in just a few seconds with the addition of few classes.
Here is the example of simple example:-
1 2 3 4 5 |
<div class="progress"> <div class="progress-bar progress-bar-success" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%;"> <span class="sr-only">60% Complete (Success)</span> </div> </div> |
Output
Learn each class and find how to create a progress bar using Bootstrap.
Simple Bootstrap Progress Bar
Create a simple progress bar to show users completion of the process, the progress of the required task and submission of the final result, etc.
To create a progress bar, use <div> tag with class .progress
and inside it use another div tag with class .progress-bar
.
The div tag with class .progress-bar
contains the attributes aria-valuenow
to show the current value, aria-valuemin
to show minimum value, aria-valuemax
to show the maximum value and style
with the width property and its value as the current value in percentage.
See the example below to understand how to create a progress bar using bootstrap.
1 2 3 4 5 |
<div class="progress"> <div class="progress-bar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%;"> <span class="sr-only">60% Complete</span> </div> </div> |
Output
Progress Bar With Labels
To show labels with the progress bar, remove the <span> tag and leave its value as it is. This will be the label of the progress bar which you can display to specify the current position value of the progress bar.
1 2 3 4 5 |
<div class="progress"> <div class="progress-bar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%;"> 60% </div> </div> |
Output
The below example showing the two progress bar with the different labels with them.
1 2 3 4 5 6 7 8 9 10 |
<div class="progress"> <div class="progress-bar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="min-width:2%;"> 2% </div> </div> <div class="progress"> <div class="progress-bar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:6%;"> 6% </div> </div> |
Output
The above example showing the first progress bar with the label 2% and a second progress bar with the label 6%.
Contextual Classes in Progress Bar
The bootstrap progress bar provides contextual classes to display the progress bars in different background colors in different situations.
Below are the contextual classes with its description.
Class Name | Description |
---|---|
.progress-bar-success |
Used to specify success progress bar and completion of the process. |
.progress-bar-info |
Display progress bar for information progress and completion. |
.progress-bar-warning |
Specify this to display the warning in the progress bar. |
.progress-bar-danger |
Show errors during the completion of the process using the progress bar. |
To create a progress bar using the contextual classes, you just need to add one of the above given classes in the table with the class .progress-bar
.
See the example below to create different progress bars using contextual classes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<div class="progress"> <div class="progress-bar progress-bar-success" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%;"> <span class="sr-only">60% Complete (Success)</span> </div> </div> <div class="progress"> <div class="progress-bar progress-bar-info" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%;"> <span class="sr-only">40% Complete (Info)</span> </div> </div> <div class="progress"> <div class="progress-bar progress-bar-warning" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width:20%;"> <span class="sr-only">20% Complete (Warning)</span> </div> </div> <div class="progress"> <div class="progress-bar progress-bar-warning" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="width:30%;"> <span class="sr-only">30% Complete (Error)</span> </div> </div> |
Output
The above given example showing different size progress bars with different colors using the bootstrap progress bar contextual classes.
Striped Progress Bar
A striped progress bar showing the progress bar with many strips as given in the example below. You can create striped progress bar by adding the .progress-bar-striped
with the class .progress-bar
.
In addition to this, you also add contextual classes to create different colored striped progress bar as given in the example below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<div class="progress"> <div class="progress-bar progress-bar-success progress-bar-striped" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%;"> <span class="sr-only">60% Complete (Success)</span> </div> </div> <div class="progress"> <div class="progress-bar progress-bar-info progress-bar-striped" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%;"> <span class="sr-only">40% Complete (Info)</span> </div> </div> <div class="progress"> <div class="progress-bar progress-bar-warning progress-bar-striped" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width:20%;"> <span class="sr-only">20% Complete (Warning)</span> </div> </div> <div class="progress"> <div class="progress-bar progress-bar-dangerprogress-bar-striped" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="width:30%;"> <span class="sr-only">30% Complete (Error)</span> </div> </div> |
Output
The above example showing the four striped progress bars using the different contextual classes for each bar.
Animated Progress Bar
You can easily display animated bootstrap progress bar by adding the class .active
. Add the class to the bar you want to make animated.
This is the fastest way provided by bootstrap to create progress bars in few seconds.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<div class="progress"> <div class="progress-bar progress-bar-success progress-bar-striped active" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%;"> <span class="sr-only">60% Complete (Success)</span> </div> </div> <div class="progress"> <div class="progress-bar progress-bar-info progress-bar-striped active" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%;"> <span class="sr-only">40% Complete (Info)</span> </div> </div> <div class="progress"> <div class="progress-bar progress-bar-warning progress-bar-striped active" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width:20%;"> <span class="sr-only">20% Complete (Warning)</span> </div> </div> <div class="progress"> <div class="progress-bar progress-bar-warning progress-bar-striped active" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="width:30%;"> <span class="sr-only">30% Complete (Error)</span> </div> </div> |
Output
The above example contains the animated progress bars with the contextual classes to display different types of progress bars.
Stacked(Multiple in the Same Line) Progress Bar
If you want to put multiple progress bars in the same line, you have to add multiple <div> with class .progress-bar
inside the another <div> with class .progress
.
1 2 3 4 5 6 7 8 9 10 11 |
<div class="progress"> <div class="progress-bar progress-bar-success" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width:20%;"> <span class="sr-only">20% Complete (Success)</span> </div> <div class="progress-bar progress-bar-info progress-bar-striped" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" style="width:10%;"> <span class="sr-only">10% Complete (Success)</span> </div> <div class="progress-bar progress-bar-danger progress-bar-striped active" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="width:30%;"> <span class="sr-only">30% Complete (Success)</span> </div> </div> |
Output
The above example contains the three different progress bars in the same line.