React Progress Component

Progress

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

Other frameworks

CoreUI components are available as native Angular, Bootstrap (Vanilla JS), and Vue components. To learn more please visit the following pages.

Example#

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.

Basic usage#

<CProgress value={0} />
<CProgress value={25} />
<CProgress value={50} />
<CProgress value={75} />
<CProgress value={100} />

Labels#

Add labels to your progress bars by placing text within the <CProgressBar>.

25%
<CProgress value={25}>25%</CProgress>

Please note that the default setting for the content within the <CProgressBar /> is to be limited by the overflow: hidden property, preventing it from extending beyond the bar's boundaries. If the progress bar is shorter than its label, the content will be truncated and could be difficult to read. To modify this behavior, you can utilize the .overflow-visible class from the overflow utilities. However, it is important to specify a specific text color to ensure readability. It's worth noting that this approach currently does not consider color modes.

Long label text for the progress bar, set to a dark color
<CProgress value={10}>
<CProgressBar className="overflow-visible text-dark px-2" color="success">Long label text for the progress bar, set to a dark color</CProgressBar>
</CProgress>

Since v4.9.0 you can also use the progressBarClassName property directly on the <CProgress /> component to achieve the same.

<CProgress progressBarClassName="overflow-visible text-dark px-2" color="success" value={10}>Long label text for the progress bar, set to a dark color</CProgress>

Height#

We only set a height value on the <CProgress>, so if you change that value the inner <CProgressBar> will automatically resize accordingly.

<CProgress height={1} value={25} />
<CProgress height={20} value={25} />
<CProgress height={1}>
<CProgressBar value={25}></CProgressBar>
</CProgress>
<CProgress height={20}>
<CProgressBar value={25}></CProgressBar>
</CProgress>

Backgrounds#

Use color prop to change the appearance of individual progress bars.

<CProgress color="success" value={25} />
<CProgress color="info" value={50} />
<CProgress color="warning" value={75} />
<CProgress color="danger" value={100} />

Ensure that when you incorporate labels into progress bars featuring a custom background color, you also select an appropriate text color to ensure readability and maintain adequate contrast for the labels.

25%
50%
75%
100%
<CProgress color="success" value={25}>
<CProgressBar>25%</CProgressBar>
</CProgress>
<CProgress color="info" value={50}>
<CProgressBar className="text-dark">50%</CProgressBar>
</CProgress>
<CProgress color="warning" value={75}>
<CProgressBar className="text-dark">75%</CProgressBar>
</CProgress>
<CProgress color="danger" value={100}>
<CProgressBar>100%</CProgressBar>
</CProgress>

Since v4.9.0 you can also use the progressBarClassName property directly on the <CProgress /> component to achieve the same.

<CProgress color="success" value={25}>25%</CProgress>
<CProgress color="info" progressBarClassName="text-dark" value={50}>50%</CProgress>
<CProgress color="warning" progressBarClassName="text-dark" value={75}>75%</CProgress>
<CProgress color="danger" value={100}>100%</CProgress>

Multiple bars#

Include multiple progress bars in a progress component if you need. In v4.9.0

New markup in v4.9.0

In version 4.9.0, we introduced a new <CProgressStacked> component to more logically wrap multiple progress bars into a single stacked progress bar. The previous structure will continue to work until the next major version.

New markup

<CProgressStacked>
<CProgress value={15} />
<CProgress color="success" value={30} />
<CProgress color="info" value={20} />
</CProgressStacked>

Previous markup

<CProgress>
<CProgressBar value={15} />
<CProgressBar color="success" value={30} />
<CProgressBar color="info" value={20} />
</CProgress>

Striped#

Add variant="striped" to any <CProgressBar> to apply a stripe via CSS gradient over the progress bar's background color.

<CProgress color="success" variant="striped" value={25} />
<CProgress color="info" variant="striped" value={50} />
<CProgress color="warning" variant="striped" value={75} />
<CProgress color="danger" variant="striped" value={100} />

Animated stripes#

The striped gradient can also be animated. Add animated property to <CProgressBar> to animate the stripes right to left via CSS3 animations.

<CProgress color="success" variant="striped" animated value={25} />
<CProgress color="info" variant="striped" animated value={50} />
<CProgress color="warning" variant="striped" animated value={75} />
<CProgress color="danger" variant="striped" animated value={100} />

Customizing#

CSS variables#

React progress bars 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.

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

How to use CSS variables#

const vars = {
'--my-css-var': 10,
'--my-another-css-var': "red"
}
return <CProgress style={vars}>...</CProgress>

SASS variables#

$progress-height: 1rem !default;
$progress-font-size: $font-size-base * .75 !default;
$progress-bg: var(--cui-secondary-bg) !default;
$progress-border-radius: var(--cui-border-radius) !default;
$progress-box-shadow: var(--cui-box-shadow-inset) !default;
$progress-bar-color: $white !default;
$progress-bar-bg: var(--cui-primary) !default;
$progress-bar-animation-timing: 1s linear infinite !default;
$progress-bar-transition: width .6s ease !default;
// TODO: clean-up ???
$progress-group-margin-bottom: $spacer !default;
$progress-group-header-margin-bottom: $spacer * .25 !default;

API#

CProgress#

import { CProgress } from '@coreui/react'
// or
import CProgress from '@coreui/react/src/components/progress/CProgress'
PropertyDescriptionTypeDefault
animatedUse to animate the stripes right to left via CSS3 animations.boolean-
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of CoreUI’s themed colors.{'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | 'primary-gradient' | 'secondary-gradient' | 'success-gradient' | 'danger-gradient' | 'warning-gradient' | 'info-gradient' | 'dark-gradient' | 'light-gradient' | string }-
heightSets the height of the component. If you set that value the inner <CProgressBar> will automatically resize accordingly.number-
progressBarClassName
4.9.0+
A string of all className you want applied to the <CProgressBar/> component.string-
thinMakes progress bar thinner.boolean-
valueThe percent to progress the ProgressBar (out of 100).number-
variantSet the progress bar variant to optional striped.'striped'-
whiteChange the default color to white.boolean-

CProgressBar#

import { CProgressBar } from '@coreui/react'
// or
import CProgressBar from '@coreui/react/src/components/progress/CProgressBar'
PropertyDescriptionTypeDefault
animatedUse to animate the stripes right to left via CSS3 animations.boolean-
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of CoreUI’s themed colors.{'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | 'primary-gradient' | 'secondary-gradient' | 'success-gradient' | 'danger-gradient' | 'warning-gradient' | 'info-gradient' | 'dark-gradient' | 'light-gradient' | string }-
valueThe percent to progress the ProgressBar.number0
variantSet the progress bar variant to optional striped.'striped'-