Bootstrap Progress Bar

The progress bar shows how far a user is in a process. In Bootstrap, there are several types of progress bars.

The class .progress within a <div> element is used to create a default progress bar in bootstrap.

Bootstrap Progress Bar Example

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Progress bar</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<div class="container">  

  <h2>Default Progress Bar</h2>  

  <div class="progress">  

    <div class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%">  

      <span class="sr-only">70% Complete</span>  

    </div>  

  </div>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

</body>  

</html> 

Bootstrap 4 Basic Progress Bar

Progress bar is used to show a user how far long he/she is in a process. To create create a default progress bar, add a .progress class to a container element and and the progress-bar class to its child element. Use the CSS width property to set the width of the progress bar.

Example

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap 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.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

  

<div class="container">  

  <h2>Progress Bar With Label</h2>  

  <div class="progress">  

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

  </div>  

</div>  

  

</body>  

</html>  

Bootstrap Progress bar with Label

The progress bar with label specifies the percentage of progress of a specific process.

You have to remove the .sr-only class from the progress bar to show a visible percentage.

See this example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap 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/3.3.6/css/bootstrap.min.css">  

  

</head>  

<body>  

  

<div class="container">  

  <h2>Progress Bar With Label</h2>  

  <div class="progress">  

    <div class="progress-bar" role="progressbar"   

    aria-valuenow="76" aria-valuemin="0" aria-valuemax="100" style="width:76%">  

      76%  

    </div>  

  </div>  

</div>  

  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

  

</body>  

</html> 

Bootstrap Colored Progress bar

You can use contextual classes to create colored progress bar.

The contextual classes that are used to create colored progress bar:

  • .progress-bar-success
  • .progress-bar-info
  • .progress-bar-warning
  • .progress-bar-danger

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap 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/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<div class="container">  

  <h2>Colored Progress Bars</h2>  

  <p>The contextual classes colors the progress bars:</p>   

  <div class="progress">  

    <div class="progress-bar progress-bar-success"   

    role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%">  

      40% Complete (success)  

    </div>  

  </div>  

  <div class="progress">  

    <div class="progress-bar progress-bar-info"   

    ole="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width:50%">  

      50% Complete (info)  

    </div>  

  </div>  

  <div class="progress">  

    <div class="progress-bar progress-bar-warning"   

    role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%">  

      60% Complete (warning)  

    </div>  

  </div>  

  <div class="progress">  

    <div class="progress-bar progress-bar-danger"   

    role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%">  

      70% Complete (danger)  

    </div>  

  </div>  

</div>  

  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

  

</body>  

</html> 

Bootstrap Stripped Progress bar

You can create stripped progress bar by using class .progress-bar-striped .

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap 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/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<div class="container">  

  <h2>Striped Progress Bars</h2>  

  <p>The .progress-bar-striped class adds stripes to the progress bars:</p>   

  <div class="progress">  

    <div class="progress-bar progress-bar-success progress-bar-striped"   

    role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%">  

      40% Complete (success)  

    </div>  

  </div>  

  <div class="progress">  

    <div class="progress-bar progress-bar-info progress-bar-striped"   

    role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width:50%">  

      50% Complete (info)  

    </div>  

  </div>  

  <div class="progress">  

    <div class="progress-bar progress-bar-warning progress-bar-striped"   

    role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%">  

      60% Complete (warning)  

    </div>  

  </div>  

  <div class="progress">  

    <div class="progress-bar progress-bar-danger progress-bar-striped"   

    role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%">  

      70% Complete (danger)  

    </div>  

  </div>  

</div>  

  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

  

</body>  

</html>  

Bootstrap Animated progress bar

You have to use class .active to create animated progress bar.

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap 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/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<div class="container">  

  <h2>Animated Progress Bar</h2>  

  <p>The .active class animates the progress bar:</p>   

  <div class="progress">  

    <div class="progress-bar progress-bar-striped active"   

    role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%">  

      70%  

    </div>  

  </div>  

</div>  

  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

  

</body>  

</html> 

Bootstrap Stacked Progress bar (Multi-colored progress bar)

You can create stacked progress bar by placing multiple bars into the same <div class=”progress”>

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap 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/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<div class="container">  

  <h2>Stacked Progress Bars</h2>  

  <p>Create a stacked progress bar by placing multiple bars into the same div with class .progress:</p>   

  <div class="progress">  

    <div class="progress-bar progress-bar-success"   

    role="progressbar" style="width:40%">  

      Free Space  

    </div>  

    <div class="progress-bar progress-bar-warning"   

    role="progressbar" style="width:10%">  

      Warning  

    </div>  

    <div class="progress-bar progress-bar-danger"   

    role="progressbar" style="width:20%">  

      Danger  

    </div>  

  </div>  

</div>  

  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

  

</body>  

</html> 

Note: Two types of new colored progress bar are added in Bootstrap 4:

  • .progress-bar-white
  • .progress-bar-secondary
  • .progress-bar-light
  • .progress-bar-dark

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap 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.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

  

<div class="container">  

  <h2>Colored Progress Bars Example</h2>  

  <!-- 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>  

  

</body>  

</html> 

    Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *