Skip to content

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

Components

Free

Progress for Radix UI

A bar that fills as a known task gets done, like an upload or a numbered step. For React with Radix UI, when people should see what is left.

The bar fills from a number your code already has. It doesn't watch the request for you.

Use it for an upload or a numbered step when people should see how much is left. If there is nothing to measure, use a Spinner. In React, Radix UI draws the bar and can leave it indeterminate when you do not know the end.

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
Progress
├── ProgressLabel
├── ProgressTrack
├── ProgressIndicator
├── ProgressValue
├── ProgressView
└── ProgressCircle
    ├── ProgressCircleTrack
    └── ProgressCircleRange

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 className="w-[60%]" value={progress} />;
};

Demos

Label

ProgressLabel names the bar, here an upload, and ProgressValue prints the percent beside it. Both sit in Progress and follow value. Use them when a bare bar on the page could be any of several tasks. The label also names the bar for assistive tech, so you can skip a separate aria-label when the visible word is the right name.

Preview width

Controlled

The bar only displays value. A Slider writes that number here so you can drag and watch the fill, which is a stand-in for the real source. In the app, the number comes from the upload or from the step you are on, and the bar will not subscribe to a request. Use a controlled value whenever the task can report how far it has gotten.

Preview width

Rtl

dir set to rtl puts the Arabic caption and the percent on a right-to-left row. The number is the same value. Use this to check a translated page, not as a variant you render only for one language. Set dir on Progress when this bar should follow a right-to-left parent even if you have not flipped the whole document. The bar fills from the right in right-to-left text on its own, so the rtl:rotate-180 a shadcn/ui snippet passes is dropped rather than flipping it back.

Preview width

FAQ

How do I update the Progress value in React?

Pass value and change it as the work advances: Progress shows the number you give it and doesn't watch your request. For an upload, set it from the request's progress events; for a multi-step task, set it per step. The Controlled demo above drives it from a Slider.

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

Pass null as value: the bar reports an indeterminate state instead of a percentage.

If there's nothing to measure at all, a Spinner says "working" more honestly than an empty bar.

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

Set max on Progress (100 by default; it starts at 0), then pass value in the same units, such as 3 with a max of 5 for the third of five steps.

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

Pass getValueLabel, which gets the value and the max, and return text such as "Step 3 of 5" in place of "60%".

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

Add ProgressLabel for the name and ProgressValue for the number inside Progress, as in the Label demo above. The value text follows value, and the label names the bar for screen readers too.

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

Progress only displays a value. If people should set the number, use a Slider; for a ring in a small space, use Circular Progress; and for work with no measurable amount, use a Spinner.

Is the Radix UI Progress accessible?

Yes. It has the progressbar role with its current, minimum and maximum values, so screen readers report the progress as it changes. Name it with ProgressLabel or an aria-label, so people know what is loading.

How do I install the Progress bar in React?

Run the command from the Installation section above: it adds Progress and the parts it uses to your project's ui folder. The shadcn CLI writes components/ui/progress.tsx, a file you own and can edit.

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