Progress Bar

Progress indicators offer visibility of system status to the user, giving feedback to indicate that the application is taking some time to processing data. The main aim of these components is to reduce the user's uncertainty about offering something to look at while the user is waiting for the end. A progress bar should be used in any scenario that will take more than 1 second in performing the action, for anything that takes less than that time, it will be distracting for the user.

Props

NameTypeDescriptionDefault
labelstringText to be placed above the progress bar.-
helperTextstringHelper text to be placed under the progress bar.-
overlaybooleanIf true, the progress bar will be displayed as a modal.false
valuenumberThe value of the progress indicator. If it's received the component is determinate otherwise is indeterminate.-
showValuebooleanIf true, the determined value is displayed above the progress bar.false
margin'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | MarginSize of the margin to be applied to the component. You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.-
ariaLabelstringSpecifies a string to be used as the name for the progress bar element when no label is provided.'Progress bar'

Examples

Basic Usage

() => (
  <DxcInset space="2rem">
    <DxcProgressBar label="Loading" />
  </DxcInset>
);

Overlay

() => {
  const [isVisible, changeIsVisible] = useState(false);
  const showModal = () => {
    changeIsVisible(true);
    fetchData().then(() => {
      changeIsVisible(false);
    });
  };
  
  const fetchData = () => {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve();
      }, 3000);
    });
  };

  return (
    <DxcInset space="2rem">
      <DxcFlex direction="column" gap="2rem" alignItems="flex-start">
        <DxcButton
          label="Show Progress Bar for 3 seconds"
          onClick={showModal}
        />
        {isVisible && (
          <DxcProgressBar
            label="Loading"
            overlay
          />
        )}
      </DxcFlex>
    </DxcInset>
  );
}