Edit Profile

Dark Mode

Copy config

Copy and paste the following code into your global.css file to apply the styles.

Progress

A visual indicator that shows how much of a task has been completed.

✨ Features

  • Follows the WAI-Aria design pattern
  • Supports indeterminate state for unknown progress
  • Allows dynamic updatess
  • Customizable value labels for accessibility

Defining the range

Min

The min prop sets a minimum starting point for the progress bar.

🎗️ Charity Fundraiser

Initial funding:$2000
Amount raised: $5000

Funding goal: $10000

Adding a value

To set a value for the progress bar, use the value prop in the Progress.Root component.

Max

The max prop defines the upper limit of the progress bar.

🧁 Tiara's Treats

Total treats:25

Number of eaten treats: 20

Status

In progress

When the task is ongoing, the progress component reflects this state.

The data-progress="in-progress" attribute is applied to the progress and its indicator.

Complete

When the task is finished, the data-progress="complete" attribute is applied.

Indeterminate progress

If the progress is uncertain, the bar should be in an indeterminate state. This occurs when the value is null.

In this state, the progress and its indicator will have the data-progress="indeterminate" attribute.

Indeterminate Example CSS

@media (prefers-reduced-motion: no-preference) {
  .progress-indicator.indeterminate {
    width: 30%;
    animation: indeterminate-slide 2s infinite cubic-bezier(0.37, 0, 0.63, 1);
  }
}

@keyframes indeterminate-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

State

Initial Progress

To set the initial progress on page load, you can pass a value prop to the Progress.Root component.

Dynamic Progress Updates

To update the progress bar in real-time, pass a signal to the bind:value prop.

The progress bar can also be used in combination with other Qwik UI headless components, such as the Carousel component when the user navigates through the slides.

CSR

Similar to other Qwik UI headless components, the Progress Bar automatically renders based on its environment. The previous progress bars are rendered on the server.

The example above shows the progress bar being rendered on the client when the isRendered signal is set to true.

Building blocks

import { component$ } from '@builder.io/qwik';
import { Progress } from '@qwik-ui/headless';

export default component$(() => {
  const progress = 30;

  return (
    <Progress.Root value={progress} class="progress">
      <Progress.Indicator
        class="progress-indicator"
        style={{
          transform: `translateX(-${100 - progress}%)`,
        }}
      />
    </Progress.Root>
  );
});

🎨 Anatomy

ComponentDescription
Progress.Root

The root container for the progress

Progress.Indicator

Displays the progression process

Example CSS

.progress {
  height: 1.75rem;
  width: 100%;
  overflow: hidden;
  border-radius: calc(var(--border-radius) / 2);
  border: 2px dotted hsl(var(--primary));
}

.progress-indicator {
  height: 100%;
  width: 100%;
  background-color: hsl(var(--primary));
}

@keyframes loading-flash {
  0% {
    opacity: 0.1;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.1;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .progress-indicator.indeterminate {
    width: 30%;
    animation: indeterminate-slide 2s infinite cubic-bezier(0.37, 0, 0.63, 1);
  }
}

@keyframes indeterminate-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

.progress-example-input {
  border-radius: calc(var(--border-radius) / 2);
  border: 2px dotted hsl(var(--primary));
  margin-left: 0.5rem;
  max-width: 3rem;
  padding: 0.25rem;
  outline: none;
}

API

Progress.Root

PropTypeDescription
value
union

Current value of the progress bar. Can be null for indeterminate state.

min
number

Minimum starting point for the progress bar.

max
number

Maximum value of the progress bar.

getValueLabel
function

A function to get the accessible label for the current value. If not provided, the label will be shown as a percentage of the range.

bind:value
Signal

A signal to bind the current value of the progress bar for reactive updates.