Bootstrap Progress Bars

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Bootstrap Progress Bars

In this tutorial you will learn how to create progress bars using Bootstrap.

Creating Progress Bar with Bootstrap

Progress bars can be used for showing the progress of a task or action to the users. The following example will show you how to create a simple progress bar with vertical gradient.

Example

  •  class="progress">
  •      class="progress-bar" style="width: 60%;">
  •          class="sr-only">60% Complete
  • 
     
  • 
     

— The output of the above example will look something like this:

Bootstrap Basic Progress Bar


Creating Progress Bar with Label

To show to the progress status as a percentage label just remove the with .sr-only class from within the progress bar as demonstrated in example above.

Example

  •  class="progress">
  •      class="progress-bar" style="width: 60%;">
  •         60%
  • 
     
  • 
     

— The output of the above example will look something like this:

Bootstrap Basic Progress Bar with Label

If you are showing percentage label you should also add a min-width to the progress bar to ensure that the label text remains readable even for low percentage, like this.

Example

  •  class="progress">
  •      class="progress-bar" style="min-width: 20px;">
  •         0%
  • 
     
  • 
     
  •  class="progress">
  •      class="progress-bar" style="min-width: 20px; width: 2%;">
  •         2%
  • 
     
  • 
     

Creating Stripped Progress Bar

To create the stripped progress bar just add an extra class .progress-striped to the .progress base class, as shown in the example below:

Example

  •  class="progress progress-striped">
  •      class="progress-bar" style="width: 60%;">
  •          class="sr-only">60% Complete
  • 
     
  • 
     

— The output of the above example will look something like this:

Bootstrap Stripped Progress Bar

Similarly you can create the animated progress bar — just add the .active class to .progress-stripped. The .active class animates the stripes from right to left.

Example

  •  class="progress progress-striped active">
  •      class="progress-bar" style="width: 60%;">
  •          class="sr-only">60% Complete
  • 
     
  • 
     

Warning:Due to lack of support for CSS3 animation properties the animated progress bar is not supported in any versions of IE upto IE9. The stripped progress bar uses CSS3 gradient to create the striped effect which is not supported in IE7-8.


Changing Progress Bar Value Dynamically

Static progress bars aren't very impressive. The following example will give you a rough idea of how to update the status of a Bootstrap progress bar dynamically using jQuery.

Example

  •  class="progress progress-striped active">
  •      class="progress-bar">
  • 
     
  • 
     
  •  

Creating Stacked Progress Bar

You can also place multiple bars into the same progress bar to stack them.

Example

  •  class="progress">
  •      class="progress-bar progress-bar-success" style="width: 40%">
  •          class="sr-only">Program Files (40%)
  • 
     
  •      class="progress-bar progress-bar-warning" style="width: 25%">
  •          class="sr-only">Residual Files (25%)
  • 
     
  •      class="progress-bar progress-bar-danger" style="width: 15%">
  •          class="sr-only">Junk Files (15%)
  • 
     
  • 
     

— The output of the above example will look something like this:

Bootstrap Stacked Progress Bar


Progress Bars with Emphasis Classes

Bootstrap also provides some emphasis utility classes for progress bars that can be further used to convey meaning through color.

Example

  •  class="progress">
  •      class="progress-bar progress-bar-info" style="width: 20%">
  •          class="sr-only">20% Used
  • 
     
  • 
     
  •  class="progress">
  •      class="progress-bar progress-bar-success" style="width: 40%">
  •          class="sr-only">40% Used
  • 
     
  • 
     
  •  class="progress">
  •      class="progress-bar progress-bar-warning" style="width: 80%">
  •          class="sr-only">80% Used
  • 
     
  • 
     
  •  class="progress">
  •      class="progress-bar progress-bar-danger" style="width: 90%">
  •          class="sr-only">90% Used
  • 
     
  • 
     

— The output of the above example will look something like this:

Bootstrap Progress Bar with Emphasis


Striped Progress Bars with Emphasis Classes

Similar to the solid colors, you can also create varied striped progress bars.

Example

  •  class="progress progress-striped">
  •      class="progress-bar progress-bar-info" style="width: 20%">
  •          class="sr-only">20% Used
  • 
     
  • 
     
  •  class="progress progress-striped">
  •      class="progress-bar progress-bar-success" style="width: 40%">
  •          class="sr-only">40% Used
  • 
     
  • 
     
  •  class="progress progress-striped">
  •      class="progress-bar progress-bar-warning" style="width: 80%">
  •          class="sr-only">80% Used
  • 
     
  • 
     
  •  class="progress progress-striped">
  •      class="progress-bar progress-bar-danger" style="width: 90%">
  •          class="sr-only">90% Used
  • 
     
  • 
     

— The output of the above example will look something like this:

Bootstrap Striped Progress Bar with Emphasis