Bootstrap 4 Progress Bar

Bootstrap Progress Bar

Bootstrap 4 offers progress bars that are used to represent the progress of tasks such as downloading a file, software installation, etc. on the computer. It represents the percentage of the work done and also the remaining work.

In bootstrap 4, the progress component is created by using  two HTML elements, CSS, some attributes instead of using default <progress> element of HTML 5.

Bootstrap 4 has several designs of progress bars, such as stacked bars, text labels, animated backgrounds, etc.

Syntax

<div class=”progress”>
             <div class=”progress-bar” style=”width: %;”>
 </div>
 </div> 

Basic Progress Bar

A basic progress bar is a simple or default progress bar that has a gray background and represents the progress of a task using primary colors.

Steps of creating Progress Bar

  • Add the .progress class in the parent <div> element. This class is used as a wrapper for representing the max value of the progress bar.
  • Add the .progress-bar class to the child <div> element that represents the progress of the task.
  • Add the width property for setting the height of the progress bars.

Syntax

<!DOCTYPE html>
 <html lang="en">
 <head>
   <title>Bootstrap Progress Bar Example</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
 </head>
 <body> 
 <div class="container">
   <h2>Basic Progress Bar</h2>
   <div class="progress">
     <div class="progress-bar" style="width:40%"></div>
   </div>
 </div> 
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
 </body>
 </html> 

Output

Bootstrap 4 Progress Bar

Progress Bar Height

Bootstrap supports the predefined properties of CSS that helps in setting the width of the progress bar accordingly. The default height of the progress bar is 16px. The CSS height property is used with the .progress  class to set the height of the progress bar.

Note: The height of the progress bar and progress bar container should always be the same.

Syntax

<!DOCTYPE html>
 <html lang="en">
 <head>
   <title>Bootstrap Progress Bar Example</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
 </head>
 <body> 
 <div class="container">
   <h2>Progress Bar Height</h2>
   <div class="progress" style="height:15px">
     <div class="progress-bar" style="width:40%;height:15px"></div>
   </div>
   <br>
   <div class="progress" style="height:30px">
     <div class="progress-bar" style="width:60%;height:30px"></div>
   </div>
   <br>
   <div class="progress" style="height:40px">
     <div class="progress-bar" style="width:70%;height:40px"></div> 
   </div>
 </div>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
 </body>
 </html> 

Output

Bootstrap 4 Progress Bar

Progress Bar Labels

The progress bar label is used to add text in the progress bar, especially for representing the progress percentage of the task that has been completed.

To add the labels in the progress bar, you have to add your text just before the closing </div> tag.

Syntax

<!DOCTYPE html>
 <html lang="en">
 <head>
   <title>Bootstrap Progress Bar Example</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
 </head>
 <body>
 <div class="container">
   <h2>Progress Bar With Label</h2>
   <div class="progress">
     <div class="progress-bar" style="width:60%">60%</div>
   </div>
 </div> 
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
 </body>
 </html> 

Output

Bootstrap 4 Progress Bar

Colored Progress Bars

Just like the other components of the progress bar, you can also set the color of the progress bar according to your need. The default color of the progress bar is blue (primary). The bootstrap 4 contextual classes are used to set the color of the progress bar.

Syntax

<!DOCTYPE html>
 <html lang="en">
 <head>
   <title>Bootstrap Progress Bar Example</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
 </head> 
 <body>
 <div class="container">
   <h2>Colored Progress Bars</h2>
   <br>
   <!-- Blue -->
   <div class="progress"> 
     <div class="progress-bar" style="width:10%"></div>
   </div><br>
   <!-- Green -->
   <div class="progress">
     <div class="progress-bar bg-success" style="width:20%"></div>
   </div><br> 
   <!-- Turquoise -->
   <div class="progress">
     <div class="progress-bar bg-info" style="width:30%"></div>
   </div><br>
   <!-- Orange -->
   <div class="progress"> 
      <div class="progress-bar bg-warning" style="width:40%"></div>
   </div><br>
   <!-- Red -->
   <div class="progress">
     <div class="progress-bar bg-danger" style="width:50%"></div>
   </div><br> 
   <!-- White -->
   <div class="progress border">
     <div class="progress-bar bg-white" style="width:60%"></div>
   </div><br>
   <!-- Grey -->
   <div class="progress">
     <div class="progress-bar bg-secondary" style="width:70%"></div>
   </div><br>
   <!-- Light Grey --> 
   <div class="progress border">
     <div class="progress-bar bg-light" style="width:80%"></div>
   </div><br>
   <!-- Dark Grey -->
   <div class="progress">
     <div class="progress-bar bg-dark" style="width:90%"></div>
   </div>
 </div> 
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
 </body>
 </html> 

Output

Bootstrap 4 Progress Bar

Striped Progress Bar

 The progress bar that has stripes with CSS color gradient over the background color of the progress bar is known as a striped progress bar.

Add the .progress-bar-striped class along with the .progress-bar class and contextual color class for creating a striped progress bar.

Syntax

<!DOCTYPE html>
 <html lang="en">
 <head>
   <title>Bootstrap Progress Bar Example</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> 
 </head>
 <body>
 <div class="container">
   <h2>Striped Progress Bars</h2>
   <div class="progress">
     <div class="progress-bar progress-bar-striped" style="width:30%"></div>
   </div>
   <br>
   <div class="progress">
     <div class="progress-bar bg-success progress-bar-striped" style="width:40%"></div>
   </div>
   <br> 
   <div class="progress">
     <div class="progress-bar bg-info progress-bar-striped" style="width:50%"></div>
   </div>
   <br>
   <div class="progress">
     <div class="progress-bar bg-warning progress-bar-striped" style="width:60%"></div>
   </div> 
   <br>
 </div>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> 
 </body>
 </html> 

Output

Bootstrap 4 Progress Bar

Animated Progress Bar

We can also animate the progress bar from right to left by using CSS 3 animation.  For creating animated progress bar you have to add the .progress-bar-animated class along with the .progress-bar class and .progress-bar-striped class.

Note: We can only animate the striped progress bars and not the default progress bars.

Syntax

<!DOCTYPE html>
 <html lang="en">
 <head>
   <title>Bootstrap Progress Bar Example</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
 </head> 
 <body>
 <div class="container">
   <h2>Animated Progress Bar</h2><br>
   <div class="progress">
     <div class="progress-bar progress-bar-striped progress-bar-animated" style="width:40%"></div>
   </div> 
 </div>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
 </body>
 </html> 

Output

Bootstrap 4 Progress Bar

Multiple Progress Bar

Bootstrap also offers the class that helps in creating multiple progress bars in the single line. You can create more than one progress bar of different colors in a single progress bar. The multiple progress bar is created when you want to display the progress of more than one task into a single progress bar. 

Syntax

<!DOCTYPE html>
 <html lang="en">
 <head>
   <title>Bootstrap Progress Bar Example</title>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
 </head> 
 <div class="container">
   <h2>Multiple Progress Bars</h2> <br>
   <div class="progress">
     <div class="progress-bar bg-success" style="width:40%">
       40% 
     </div>
     <div class="progress-bar bg-warning" style="width:10%">
       10%
     </div>
     <div class="progress-bar bg-danger" style="width:20%"> 
       20%
     </div>
   </div>
 </div>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> 
   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
 </body>
 </html> 

Output

Bootstrap 4 Progress Bar

Related Topics

Bootstrap Buttons Groups

Bootstrap 4 Button Group Bootstrap 4 provides a feature button group that helps in creating a series of buttons together in a group. Basic Button Group  The .btn-group class is used within the <div> tag to create a...

6 minutes read.

Bootstrap 4 Buttons

Bootstrap Buttons Bootstrap provides many custom button styles. These buttons are used in forms and dialog boxes for actions. Bootstrap offers various predefined classes for providing styles to buttons. There are many classes that are used...

7 minutes read.

Bootstrap Protocol (BOOTP)

In the following article, we will learn about the Bootstrap Protocol and how it maintains contracts among linked devices on webwork. What is Bootstrap Protocol? The Bootstrap Protocol is a webwork contract...

3 minutes read.

Bootstrap 4 navbar

A navigation navbar or navbar uses in every website to make it more user-friendly. Navigating through the website is easier, and the user can instantly search for the topic of...

8 minutes read.

Bootstrap 4 Layout

Containers Containers are the essential elements of the bootstrap layout. It is required when we are using a bootstrap grid system. Containers can also be nested, but most layouts do not need nested containers. Bootstrap has...

3 minutes read.

Bootstrap 4 Utilities

Bootstrap 4 Utilities Bootstrap 4 utilities also known as helper classes that are used to add more style to the components. Utilities are used to make the website or webpage more stylish or elegant....

10 minutes read.

Bootstrap First Example

1) Add HTML5 doctype Before starting the example of Bootstrap, we should know about the some basic rules of Bootstrap. We have to add HTML5 doctype with lang element and CSS properties. <!DOCTYPE html>   <html lang="en">     <head>       <meta charset="utf-8">      </head>   </html> 2) Bootstrap...

2 minutes read.

Bootstrap 4 Progress Bar

Bootstrap Progress Bar Bootstrap 4 offers progress bars that are used to represent the progress of tasks such as downloading a file, software installation, etc. on the computer. It represents the percentage of the...

9 minutes read.

Bootstrap Badges and Labels

Bootstrap Badges Bootstrap Badges are numerical indicators. It is used to show that how many items are associated with a link.The .badge class is used to create of Bootstrap Badges. Let us see...

2 minutes read.

Bootstrap 4 Flex

Bootstrap 4 Flex Flex is a Bootstrap 4 component used to manage the layout, navigation bar, grid columns, sizing, alignment, and other components. The flexbox or flex utility is the replacement...

26 minutes read.

Bootstrap 4 Tutorial

What is Bootstrap? Bootstrap is a CSS (Cascading Style Sheets) framework, which is used to develop a responsive website. It is an open-source and mobile-first front-end framework. It has design templates that are based...

4 minutes read.

Bootstrap 4 Collapse

Bootstrap 4 Collapse Collapse is a bootstrap component that is similar to the dropdown button. Collapse is used to hide or show the content such as paragraphs, sentences, etc.  When we click on a...

4 minutes read.

Bootstrap 4 Popover

Bootstrap 4 Popover Popover A popover is similar to the tooltip. The only difference between tooltip and Popover is that in the tooltip, the popup box appears when you move the cursor...

6 minutes read.

Bootstrap 4 Grid System

Bootstrap 4 Grid System The bootstrap 4 grid system is used to create a responsive website layout. The bootstrap 4 offers a mobile-first flexbox grid system that allows you to divide...

4 minutes read.

Bootstrap 4 Inputs

Bootstrap Inputs Bootstrap Form Inputs – Several pre-defined input types are available in HTML and Bootstrap. These input types help in styling the forms. When an input type is specified in the form, it means...

10 minutes read.

Bootstrap Multiselect Dropdown

What is a multi-select Dropdown? Multi-select dropdown lists are used when we want to select multiple options for a particular record. Usually, dropdown lists provide the feature of choosing just one value...

4 minutes read.

Bootstrap 4 Jumbotron

Bootstrap 4 Jumbotron Bootstrap offers Jumbotron, which is used to get more attention to specific content or information on the web page. It provides a gray background-color to the content to make that content...

2 minutes read.

Difference between Bootstrap and WordPress

What is WordPress? WordPress is a free open-source CMS (Content Management System) that is written using Hypertext Pre-processor (PHP) and is paired with MySQL and is supported with HTTPS (Hypertext Transfer...

3 minutes read.

Bootstrap Datepicker

What is a Bootstrap Datepicker? It is used to display a calendar with the date, month, and time from a dropdown menu. We will use an example to see how the date...

5 minutes read.

Difference between bootstrap.css and bootstrap-theme.css

The "bootstrap.css" uses to create a website with pre-existing designs and context. It uses basic Bootstrap classes like rows and columns with a CSS styling tool. The website is styled...

5 minutes read.