Skip to content

Progress Bars

The Progress component provides a visual indicator of an operation’s progress. It supports various styles, types, and customization options to fit different UI requirements.

  • Metro UI Core
  • DOM library
<!-- Basic progress bar -->
<div data-role="progress" data-value="50"></div>
<!-- Progress bar with label and value -->
<div data-role="progress" data-value="75" data-show-label="true" data-show-value="true"></div>
<!-- Small progress bar -->
<div data-role="progress" data-value="25" data-small="true"></div>
<!-- Standard progress bar (default) -->
<div data-role="progress" data-type="bar" data-value="60"></div>
<!-- Buffer progress bar -->
<div data-role="progress" data-type="buffer" data-value="40" data-buffer="70"></div>
<!-- Loading animation -->
<div data-role="progress" data-type="load"></div>
<!-- Line progress animation -->
<div data-role="progress" data-type="line"></div>
<!-- Segmented progress bar -->
<div data-role="progress" data-type="segment" data-value="50" data-segment-size="15"></div>
<!-- Primary colored progress bar -->
<div data-role="progress" data-value="65" class="progress-primary"></div>
<!-- Success colored progress bar -->
<div data-role="progress" data-value="80" class="progress-success"></div>
<!-- Warning colored progress bar -->
<div data-role="progress" data-value="45" class="progress-warning"></div>
<!-- Alert colored progress bar -->
<div data-role="progress" data-value="30" class="progress-alert"></div>
ParameterTypeDefaultDescription
progressDeferrednumber0Delay before progress animation starts
showValuebooleanfalseWhether to show the progress value
showLabelbooleanfalseWhether to show the progress label
labelstring"Progress:"Text for the progress label
valuenumber0Initial progress value (0-100)
buffernumber0Initial buffer value (0-100) for buffer type
typestring"bar"Progress type: “bar”, “buffer”, “load”, “line”, or “segment”
smallbooleanfalseWhether to use the small variant
segmentSizenumber10Size of segments for segment type
clsProgressstring""Additional CSS class for the progress component
clsBackstring""Additional CSS class for the background
clsBarstring""Additional CSS class for the progress bar
clsBufferstring""Additional CSS class for the buffer bar
clsValuestring""Additional CSS class for the value display
clsLabelstring""Additional CSS class for the label
clsDatastring""Additional CSS class for the data container
EventDescription
onValueChangeTriggered when the progress value changes
onBufferChangeTriggered when the buffer value changes
onCompleteTriggered when the progress value reaches 100%
onBufferedTriggered when the buffer value reaches 100%
onProgressCreateTriggered when the progress component is created

The Progress component provides the following methods:

  • val(v) - Get or set the progress value. If v is provided, sets the progress value (0-100). If not, returns the current value.
  • buff(v) - Get or set the buffer value. If v is provided, sets the buffer value (0-100). If not, returns the current buffer value.
  • changeValue() - Update the progress value from the data-value attribute.
  • changeBuffer() - Update the buffer value from the data-buffer attribute.
// Get the progress component
const progress = Metro.getPlugin('#myProgress', 'progress');
// Set progress value to 75%
progress.val(75);
// Get current progress value
const currentValue = progress.val();
// Set buffer value to 90%
progress.buff(90);
VariableDefault (Light)Dark ModeDescription
--progress-bar-height12px12pxHeight of the progress bar (6px for small variant)
--progress-bar-radius8px8pxBorder radius of the progress bar (4px for small variant)
--progress-bar-back-color#eeeeee#363942Background color of the progress bar
--progress-bar-color#60A917#60A917Color of the progress bar
--progress-bar-buffer-color#CE352C#CE352CColor of the buffer indicator
--progress-bar-line-color#b3d4fc#b3d4fcColor of the line animation
--progress-bar-line-back-color#004D6F#004D6FBackground color of the line animation
--progress-bar-load-colorradial gradientradial gradientColor of the loading animation
--progress-bar-value-color#191919#ffffffColor of the value text
/* Custom styling for progress bar */
#custom-progress {
--progress-bar-height: 16px;
--progress-bar-radius: 10px;
--progress-bar-color: #2196f3;
--progress-bar-back-color: #e3f2fd;
--progress-bar-buffer-color: #ff9800;
}
  • .progress-component - Main container for the progress component
  • .progress - Progress bar container
  • .progress-data - Container for label and value
  • .progress-label - Label text
  • .progress-value - Value text
  • .small - Small variant of the progress bar
  • .with-load - Applied to load type progress
  • .line - Applied to line type progress
  • .segments - Applied to segment type progress
  • .bar - Main progress bar
  • .buffer - Buffer indicator
  • .load - Loading animation
  • .segment - Individual segment in segmented progress
  • .progress-[color] - Sets both progress bar color and background color
  • .bar-[color] - Sets only the progress bar color

Available colors include: primary, secondary, success, alert, warning, yellow, orange, red, pink, purple, violet, blue, cyan, green, lime, teal, brown, gray, dark.

  1. Choose the appropriate progress type for your use case:
  • Use “bar” for simple progress indication
  • Use “buffer” when showing both progress and buffering (like in media players)
  • Use “load” or “line” for indeterminate operations
  • Use “segment” for step-based processes
  1. Consider using the small variant for less prominent UI elements

  2. Add labels and values for important progress indicators to provide context

  3. Use color classes to match your application’s color scheme and to indicate different types of operations

  4. For accessibility, ensure sufficient contrast between the progress bar and its background

  5. Update progress values programmatically for dynamic operations:

const progress = Metro.getPlugin('#downloadProgress', 'progress');
// Update progress as download progresses
function updateDownloadProgress(percent) {
progress.val(percent);
}