configure()

BProgress.configure() method

The configure() method updates the default settings of the progress bar.

Usage

BProgress.configure({
  minimum: 0.08,
  maximum: 1,
  template: `<div class="bar"><div class="peg"></div></div>
             <div class="spinner"><div class="spinner-icon"></div></div>
             <div class="indeterminate"><div class="inc"></div><div class="dec"></div></div>`,
  easing: 'linear',
  positionUsing: 'width',
  speed: 200,
  trickle: true,
  trickleSpeed: 200,
  showSpinner: true,
  indeterminate: false,
  indeterminateSelector: '.indeterminate',
  barSelector: '.bar',
  spinnerSelector: '.spinner',
  parent: 'body',
  direction: 'ltr',
});

Typing

BProgress.configure(options: Partial<BProgressOptions>): BProgress;

BProgressOptions

interface BProgressOptions {
  minimum?: number;
  maximum?: number;
  template?: string | null;
  easing?: string;
  speed?: number;
  trickle?: boolean;
  trickleSpeed?: number;
  showSpinner?: boolean;
  parent?: HTMLElement | string;
  positionUsing?: BProgressPositionUsing;
  barSelector?: string;
  indeterminateSelector?: string;
  spinnerSelector?: string;
  direction?: BProgressDirection;
  indeterminate?: boolean;
}

BProgressPositionUsing

type BProgressPositionUsing =
  | 'translate3d'
  | 'translate'
  | 'margin'
  | 'width'
  | '';

BProgressDirection

type BProgressDirection = 'ltr' | 'rtl';

Options

NameTypeDefaultDescription
minimumnumber0.08The minimum percentage value between 0 and 1.
maximumnumber1The maximum percentage value between 0 and 1.
templatestring | null<div class="bar"><div class="peg"></div></div><div class="spinner"><div class="spinner-icon"></div></div>The template of the progress bar. Classes needs to match with the barSelector and spinnerSelector options.
easingstring'linear'The easing of the progress bar.
positionUsingBProgressPositionUsing'width'The position using of the progress bar.
speednumber200The speed of the progress bar.
tricklebooleantrueIf true, the progress bar will trickle.
trickleSpeednumber200The speed of the trickle.
showSpinnerbooleantrueIf true, the progress bar will show the spinner.
barSelectorstring'.bar'The bar selector.
spinnerSelectorstring'.spinner'The spinner selector.
parentHTMLElement | string'body'The parent container of the progress bar. (if template is not null)
directionBProgressDirection'ltr'The direction of the progress bar.
indeterminatebooleanfalseIf true, the progress bar will be indeterminate.
indeterminateSelectorstring'.indeterminate'The indeterminate selector.

Advanced Usage

Use template: null

template: null lets you add the progress bar to your code. You'll need to add an element like this:

<div class="bprogress" style="display: none">
  <div class="bar">
    <div class="peg"></div>
  </div>
  <div class="spinner">
    <div class="spinner-icon"></div>
  </div>
  <div class="indeterminate">
    <div class="inc"></div>
    <div class="dec"></div>
  </div>
</div>

It's very important to have a div with the bprogress class and the display:none style surrounding the template. For the template, classes need to match with the barSelector and spinnerSelector options.

Warning

When using a custom component for the progress bar, the component will not be dynamically added or removed from the DOM. Instead, it will simply toggle between display: block and display: none.
This behavior may impact performance, especially if the component involves complex rendering or layout calculations.

Use indeterminate: true

The indeterminate option set the progress bar to an indeterminate state. This is useful when the progress is unknown or indeterminate.

BProgress.configure({
  indeterminate: true,
});

Warning

When indeterminate is set to true, the progress bar will be indeterminate, and the inc(), dec(), trickle(), pause(), resume() and set() methods will not work.

On this page