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 withvalue
prop. -
The
MDBProgressBar
has automatically addedrole
andaria
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' style={{ width: '75%' }} 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>
|
className
|
String | '' |
Add custom classes to MDBProgressBar element |
<MDBProgress
className="test"><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>
|
className
|
String | '' |
Add custom classes to MDBProgressBar element |
<MDBProgress><MDBProgressBar
className="test"/></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>
|