Skip to content

shadcn.io is an independent project built on shadcn/ui

Components

Free

Progress for Radix UI

A progress bar for React on Radix UI that fills from the value you pass, for uploads and numbered steps, with an optional label and percent.

On this page9 sections

A progress bar shows how far a task with a known end has gotten: an upload, an import, the third of five setup steps. It fills from the value you pass and redraws when that number changes. It never watches the request itself.

When there's no number to report, a Spinner is the honest choice. For a ring that fits a tight corner, use Circular Progress, and when people should set the number themselves, a Slider.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Progress anatomy: root, label, value, track, indicator

Usage

import { useEffect, useState } from "react";
import { Progress } from "@/components/ui/progress";
const ProgressDemo = () => {
  const [progress, setProgress] = useState(13);

  useEffect(() => {
    const timer = setTimeout(() => setProgress(66), 500);
    return () => clearTimeout(timer);
  }, []);

  return <Progress aria-label="Loading" className="w-[60%]" value={progress} />;
};

The timer stands in for real work: half a second after mount it moves value from 13 to 66, and the fill slides to match. In your app the number comes from the upload or the job that reports it. With no visible label, aria-label gives the bar its name.

Accessibility

Progress is Radix UI's root, a div with the progressbar role that carries aria-valuenow, an aria-valuemin of 0, aria-valuemax and an aria-valuetext such as "56%". Radix UI doesn't name the bar, so Progress points its aria-labelledby at the ProgressLabel inside. When the design has no visible label, pass aria-label to Progress instead.

Demos

Label

An upload bar at 56%, with ProgressLabel reading "Upload progress" on one side and ProgressValue printing the percent on the other, both inside Progress. Use it when the page runs more than one task, or the bar sits far from the thing it measures. The label also becomes the bar's name for screen readers.

Preview width

Controlled

A bar at 50% with a Slider under it that writes into the same state, so dragging the thumb moves the fill. The slider stands in for the real source. In an app, value comes from an upload's progress events or from the step a setup flow is on. Reach for this pattern whenever the work can report how far it has gotten.

Preview width

RTL

The upload bar with an Arabic label and dir set to rtl on Progress. The label moves to the right, the percent to the left, and the fill grows from the right edge. Use it on an Arabic or Hebrew page, where setting dir on any parent turns every bar inside it the same way.

Preview width

FAQ

How do I update a Progress bar from a file upload in React?

Keep the percent in state and pass it as value: the bar redraws on every change and never reads the request itself. For an upload, XMLHttpRequest reports bytes sent through upload.onprogress, and loaded / total * 100 is the number to store. fetch has no upload progress event, so a bar driven by it can only jump from start to finish.

With no value, Radix UI treats the bar as indeterminate, so pass 0 when the upload starts.

How do I show an indeterminate Progress bar when I don't know how long it will take?

Pass null as value, or leave it out. The bar drops aria-valuenow and aria-valuetext, and the root and indicator get data-state set to indeterminate.

The indicator then fills the whole track and pulses, so the bar reads as busy rather than empty or finished. The pulse is a fade, not movement, so it keeps running under reduced motion. For another look, change the indicator's classes for that state in components/ui/progress, or show a Spinner, which says "working" without a number.

How do I count steps instead of percent with the Radix UI Progress?

Set max on Progress to the number of steps and pass the current step as value: 3 with a max of 5 fills 60% of the track. Radix UI always starts at 0 and has no min. ProgressValue prints a percent unless its child is a function, which receives that text, so return "Step 3 of 5" from it instead.

How do I change what screen readers hear for the Radix UI Progress?

Pass getValueLabel to Progress. It receives value and max and returns the aria-valuetext, such as "Step 3 of 5" in place of "60%". ProgressValue works out its own percent and ignores it, so give that part a function child that returns the same words when the screen should match.

How do I show a label and the percentage next to the Progress bar?

Put ProgressLabel and ProgressValue inside Progress, ahead of the track it renders for you, as the Label demo does. The root is a flex row that wraps, so the two share the first line with the value pushed to the far end, and the track takes the full width beneath them.

ProgressLabel also becomes the bar's accessible name, so it needs no aria-label.

How do I change the color or height of a Progress bar?

Progress renders its track and indicator for you, so reach them from the classes you pass to Progress, matching their data-slot. *:data-[slot=progress-track]:h-3 makes the track taller, and **:data-[slot=progress-indicator]:bg-emerald-500 recolors the fill. The first selector matches direct children only, and the indicator sits one level deeper, inside the track.

For a look every bar in the app should share, edit ProgressTrack and ProgressIndicator in components/ui/progress, which is your code once installed.

What happens when a Progress value goes past max?

Progress clamps it between 0 and max before Radix UI sees it, since Radix UI logs an error for a value outside them and reports the bar as indeterminate. A value above max fills the whole track and reports max to screen readers, and one below 0 leaves it empty. Nothing breaks, but a bar sitting at 100% while work goes on points at max and value counting different things, such as kilobytes against bytes.

When should I use a Slider or a Circular Progress instead of a Progress bar?

Progress reports a number your code sets, and nobody can move it. When people should choose the value, such as a volume or a price ceiling, use a Slider, which takes focus and answers to the arrow keys.

Circular Progress shows the same kind of value as a ring, for a card corner or a button where a full-width bar won't fit. A Spinner covers work with no amount to measure, like waiting on a server response.

API Reference

Progress

<div> data-slot="progress"

PropType
getValueLabel?{ bivarianceHack(value: number, max: number): string; }["bivarianceHack"]

Returns the text screen readers announce for the value, given the value and max.

Type
{ bivarianceHack(value: number, max: number): string; }["bivarianceHack"]
max?number

The highest value.

Default
100
value?number | null

The value.

Type
number | null
asChild?boolean

Merge props onto the child element instead of rendering a host.

className?string

Merged with the part's classes.

ProgressTrack

<div> data-slot="progress-track"

PropType
className?string

Merged with the part's classes.

ProgressIndicator

data-slot="progress-indicator"

PropType
asChild?boolean

Merge props onto the child element instead of rendering a host.

className?string

Merged with the part's classes.

ProgressRange

PropType
asChild?boolean

Merge props onto the child element instead of rendering a host.

ProgressLabel

<span> data-slot="progress-label"

PropType
className?string

Merged with the part's classes.

ProgressValue

<span>

PropType
className?string

Merged with the part's classes.

useProgress