Bootstrap 4 progress bars specify the progress of the current action or task.
Basic steps to create Bootstrap 4 Progress Bars.
.progress
class to parent container. .progress-bar
class to inner container i.e child element of parent container having class .progress
. Note: You can provide width and height of progress bar by using CSS.To set the height of the progress bar,use inline style sheet inside .progress
element and to set width of the progress bar use inline style sheet inside .progress-bar
element.
General Syntax
<div class="progress">
<div class="progress-bar" style="width: 70%;">60%</div>
</div>
Source Code
<div class="container mt-5">
<div class="progress">
<div class="progress-bar" style="width: 70%;">60%</div>
</div>
</div>
Try it yourself
Source Code : Output
Note:
To set the height of the progress bar, use inline style sheet inside .progress
element and to set width of the progress bar use inline style sheet inside .progress-bar
element.
To create progress-bar label, you have to write progress bar message inside progress bar i.e. element containing .progress-bar
class.
General Syntax
<div class="progress">
<div class="progress-bar" style="width: 60%;">60%</div>
</div>
Source Code
<div class="container mt-5 text-center">
<div class="progress">
<div class="progress-bar" style="width: 60%;">60%</div>
</div>
</div>
Try it yourself
Source Code : Output
Remember: Write progress bar lable information inside the <div>
having .progress-bar
.
Please keep in mind that by default height of the progress bar is 16px. It could be changed by applying CSS height property to the element containing .progress
class.
General Syntax
<div class="progress" style="height: 30px;">
<div class="progress-bar" style="width: 50%;"></div>
</div>
Source Code
<div class="container mt-5 text-center">
<div class="progress" style="height: 30px;">
<div class="progress-bar" style="width: 50%;"></div>
</div>
</div>
Try it yourself
Source Code : Output
Note: Progress bar height can be changes by assign CSS height
property of the element having .progress
class.
Bootstrap striped progress bar can be created very easily by adding extra .progress-bar-striped
class to the .progress-bar
element.
General Syntax
<div class="progress">
<div class="progress-bar progress-bar-striped" style="width: 70%;"></div>
</div>
Source Code
<div class="container mt-5 text-center">
<div class="progress">
<div class="progress-bar progress-bar-striped" style="width: 70%;"></div>
</div>
</div>
Try it yourself
Source Code : Output
Attention:
To create striped progress bar add .progress-bar-striped
to the child element having .progress-bar
class.
Add .progress-bar-striped
class to the element having .progress-bar.progress-bar-striped
class.
General Syntax
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:70%">70%</div>
Source Code
<div class="container mt-5 text-center">
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:70%">70%</div>
</div>
Try it yourself
Source Code : Output
Note:
To create animated progress bar use,.progress-bar-animated
to the element having .progress-bar
class.
To create multiple progress bar, put multiple progress bar element having .progress-bar
class inside parent container having .progress
class.
General Syntax
<div class="progress">
<div class="progress-bar bg-success" style="width: 40%;">Free Space</div>
<div class="progress-bar bg-danger" style="width: 20%;">Danger</div>
<div class="progress-bar bg-warning" style="width: 10%;">Warning</div>
</div>
Source Code
<div class="container mt-5 text-center">
<div class="progress">
<div class="progress-bar bg-success" style="width: 40%;">Free Space</div>
<div class="progress-bar bg-danger" style="width: 20%;">Danger</div>
<div class="progress-bar bg-warning" style="width: 10%;">Warning</div>
</div>
</div>
Try it yourself
Source Code : Output
Note:
Multiple progress bar can be created by assigning multiple progress bar element inside the parent container having .progress
class.
To create a colored progress bar, you have to use Bootstrap 4 contextual background classes.
General Syntax
<div class="progress">
<div class="progress-bar bg-success" style="width: 20%;"></div>
</div>
<div class="progress">
<div class="progress-bar bg-info" style="width: 30%;"></div>
</div>
Source Code
<div class="container mt-5">
<div class="progress">
<div class="progress-bar bg-success" style="width: 20%;"></div>
</div>
<div class="progress">
<div class="progress-bar bg-info" style="width: 30%;"></div>
</div>
</div>
Try it yourself
Source Code : Output
Note:
Add followings background contextual classes to provide different color.These background contextual classes are:
.bg-success
,.bg-info
,.bg-warning
,.bg-danger
,.bg-white
,
.bg-secondary
,.bg-light
,.bg-dark