Progress

React Bootstrap 5 Progress component

Documentation and examples for using custom progress bars featuring support for stacked bars, animated backgrounds, and text labels.


Basic example

        
            
          import React from 'react';
          import { MDBProgress, MDBProgressBar } from 'mdb-react-ui-kit';
          
          export default function App() {
            return (
              <MDBProgress>
                <MDBProgressBar width={75} valuemin={0} valuemax={100} />
              </MDBProgress>
            );
          }
          
        
    

How it works

Progress components are built with two HTML elements, some CSS to set the width, and a few attributes. We don’t use the HTML5 <progress> element, ensuring you can stack progress bars, animate them, and place text labels over them.

  • We use the MDBProgress as a wrapper to indicate the max value of the progress bar.
  • We use the inner MDBProgressBar to indicate the progress so far.
  • Widht of the MDBProgressBar can be set with value prop.
  • The MDBProgressBar has automatically added role and aria attributes to make it accessible.

Put that all together, and you have the following examples.

        
            
          import React from 'react';
          import { MDBProgress, MDBProgressBar } from 'mdb-react-ui-kit';
          
          export default function App() {
            return (
              <>
                <MDBProgress>
                  <MDBProgressBar valuenow={0} valuemin={0} valuemax={100} />
                </MDBProgress>
    
                <br />
    
                <MDBProgress>
                  <MDBProgressBar width='25' valuemin={0} valuemax={100} />
                </MDBProgress>
    
                <br />
    
                <MDBProgress>
                  <MDBProgressBar width='50' valuemin={0} valuemax={100} />
                </MDBProgress>
    
                <br />
    
                <MDBProgress>
                  <MDBProgressBar width='75' valuemin={0} valuemax={100} />
                </MDBProgress>
    
                <br />
    
                <MDBProgress>
                  <MDBProgressBar width='100' valuemin={0} valuemax={100} />
                </MDBProgress>
              </>
            );
          }
          
        
    

MDB provides a handful of utilities for setting width. Depending on your needs, these may help with quickly configuring progress.

        
            
          import React from 'react';
          import { MDBProgress, MDBProgressBar } from 'mdb-react-ui-kit';
          
          export default function App() {
            return (
              <MDBProgress>
                <MDBProgressBar className='w-75' valuenow={75} valuemin={0} valuemax={100} />
              </MDBProgress>
            );
          }
          
        
    

Labels

Add labels to your progress bars by placing text within the MDBProgress.

To make the label visible you need to set a proper height to the bar.

        
            
          import React from 'react';
          import { MDBProgress, MDBProgressBar } from 'mdb-react-ui-kit';
          
          export default function App() {
            return (
              <MDBProgress height='20'>
                <MDBProgressBar width='25' valuemin={0} valuemax={100}>
                  25%
                </MDBProgressBar>
              </MDBProgress>
            );
          }
          
        
    

Height

We only set a height value on the MDBProgress, so if you change that value the inner MDBProgressBar will automatically resize accordingly.

        
            
          import React from 'react';
          import { MDBProgress, MDBProgressBar } from 'mdb-react-ui-kit';
          
          export default function App() {
            return (
              <>
                <MDBProgress height='1'>
                  <MDBProgressBar width='25' valuemin={0} valuemax={100} />
                </MDBProgress>
    
                <br />
    
                <MDBProgress height='20'>
                  <MDBProgressBar width='25' valuemin={0} valuemax={100} />
                </MDBProgress>
              </>
            );
          }
          
        
    

Colors

Use background utility classes to change the appearance of individual progress bars.

        
            
          import React from 'react';
          import { MDBProgress, MDBProgressBar } from 'mdb-react-ui-kit';
          
          export default function App() {
            return (
              <>
                <MDBProgress>
                  <MDBProgressBar bgColor='success' width='25' valuemin={0} valuemax={100} />
                </MDBProgress>
    
                <br />
    
                <MDBProgress>
                  <MDBProgressBar bgColor='info' width='50' valuemin={0} valuemax={100} />
                </MDBProgress>
    
                <br />
    
                <MDBProgress>
                  <MDBProgressBar bgColor='warning' width='75' valuemin={0} valuemax={100} />
                </MDBProgress>
    
                <br />
    
                <MDBProgress>
                  <MDBProgressBar bgColor='danger' width='100' valuemin={0} valuemax={100} />
                </MDBProgress>
              </>
            );
          }
          
        
    

Multiple bars

Include multiple progress bars in a progress component if you need.

        
            
          import React from 'react';
          import { MDBProgress, MDBProgressBar } from 'mdb-react-ui-kit';
          
          export default function App() {
            return (
              <MDBProgress>
                <MDBProgressBar width='15' valuemin={0} valuemax={100} />
                <MDBProgressBar bgColor='success' width='30' valuemin={0} valuemax={100} />
                <MDBProgressBar bgColor='info' width='20' valuemin={0} valuemax={100} />
              </MDBProgress>
            );
          }
          
        
    

Striped

Add striped to any MDBProgressBar to apply a stripe via CSS gradient over the progress bar’s background color.

        
            
          import React from 'react';
          import { MDBProgress, MDBProgressBar } from 'mdb-react-ui-kit';
          
          export default function App() {
            return (
              <>
                <MDBProgress>
                  <MDBProgressBar striped width='10' valuemin={0} valuemax={100} />
                </MDBProgress>
                <br />
                <MDBProgress>
                  <MDBProgressBar striped bgColor='success' width='25' valuemin={0} valuemax={100}></MDBProgressBar>
                </MDBProgress>
                <br />
                <MDBProgress>
                  <MDBProgressBar striped bgColor='info' width='50' valuemin={0} valuemax={100} />
                </MDBProgress>
                <br />
                <MDBProgress>
                  <MDBProgressBar striped bgColor='warning' width='75' valuemin={0} valuemax={100} />
                </MDBProgress>
                <br />
                <MDBProgress>
                  <MDBProgressBar striped bgColor='danger' width='100' valuemin={0} valuemax={100} />
                </MDBProgress>
              </>
            );
          }
          
        
    

Animated stripes

The striped gradient can also be animated. Add animated to MDBProgressBar to animate the stripes right to left via CSS3 animations.

        
            
          import React from 'react';
          import { MDBProgress, MDBProgressBar } from 'mdb-react-ui-kit';
          
          export default function App() {
            return (
              <MDBProgress>
                <MDBProgressBar striped animated width='75' valuemin={0} valuemax={100} />
              </MDBProgress>
            );
          }
          
        
    

Progress - API


Import

        
            
        import { 
          MDBProgress,
          MDBProgressBar
        } from 'mdb-react-ui-kit';
      
        
    

Properties

MDBProgress

Name Type Default Description Example
tag String 'div' Defines tag of the MDBProgress element <MDBProgress tag="section"><MDBProgressBar/></MDBProgress>
height Number | String Sets the height of the MDBProgress and MDBProgressBar elements <MDBProgress :height="10"><MDBProgressBar/></MDBProgress>

MDBProgressBar

Name Type Default Description Example
tag String 'li' Defines tag of the MDBProgressBar element <MDBProgress><MDBProgressBar tag="section"/></MDBProgress>
bgColor String Sets background color of the MDBProgressBar element. <MDBProgress><MDBProgressBar bgColor="success"/></MDBProgress>
striped Boolean false Adds striped effect <MDBProgress><MDBProgressBar striped></MDBProgress>
animated Boolean false Adds animation effect <MDBProgress><MDBProgressBar animated></MDBProgress>
valuenow Number 0 Changes progress value <MDBProgress><MDBProgressBar valuenow="10"></MDBProgress>
valuemin Number 0 Changes minimum progress value <MDBProgress><MDBProgressBar valuemin="10"></MDBProgress>
valuemax Number 100 Changes maximum progress value <MDBProgress><MDBProgressBar valuemax="10"></MDBProgress>
width Number | String 100 Change width of MDBProgressBar element <MDBProgress><MDBProgressBar valuemax="10"></MDBProgress>

CSS variables

As part of MDB’s evolving CSS variables approach, progress now use local CSS variables on .progress for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.

        
            
        // .progress
        --#{$prefix}progress-height: #{$progress-height};
        @include rfs($progress-font-size, --#{$prefix}progress-font-size);
        --#{$prefix}progress-bg: #{$progress-bg};
        --#{$prefix}progress-border-radius: #{$progress-border-radius};
        --#{$prefix}progress-box-shadow: #{$progress-box-shadow};
        --#{$prefix}progress-bar-color: #{$progress-bar-color};
        --#{$prefix}progress-bar-bg: #{$progress-bar-bg};
        --#{$prefix}progress-bar-transition: #{$progress-bar-transition};
        
        
    

SCSS variables

        
            
        $progress-height: 4px;
        $progress-font-size: $font-size-base * 0.75;
        $progress-bg: $gray-200;
        $progress-border-radius: $border-radius;
        $progress-box-shadow: $box-shadow-inset;
        $progress-bar-color: $white;
        $progress-bar-bg: $primary;
        $progress-bar-animation-timing: 1s linear infinite;
        $progress-bar-transition: width 0.6s ease;