Progress Bar

ProgressBar communicates the progress of a task or loading operation.

65%
12 of 18 files uploaded
tsx
import { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';

<ProgressBar value={65}>
  <ProgressBar.Header>
    <ProgressBar.Label>Uploading assets</ProgressBar.Label>
    <ProgressBar.Value />
  </ProgressBar.Header>
  <ProgressBar.Track />
  <ProgressBar.Description>12 of 18 files uploaded</ProgressBar.Description>
</ProgressBar>

Installation

pnpm dlx wideset add progress-bar

Copies the component and any Wideset components it uses into your project.

Examples

Types

The bar spans its container and carries a label, the percentage and a description, so it suits an upload or a long task the user is watching. The circle is a compact ring, with the percentage beside it when you compose ProgressBar.Value, for a table row, a file list or a sidebar where a full-width bar does not fit; it has no label, so name it with aria-label. Both announce their value to screen readers as a progressbar.

tsx
import { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';

export default function ProgressBarTypes() {
  return (
    <div className="gap-ws-12 flex w-[20rem] max-w-full flex-col">
      <ProgressBar type="bar" value={50}>
        <ProgressBar.Header>
          <ProgressBar.Label>Uploading assets</ProgressBar.Label>
          <ProgressBar.Value />
        </ProgressBar.Header>
        <ProgressBar.Track />
        <ProgressBar.Description>9 of 18 files uploaded</ProgressBar.Description>
      </ProgressBar>
      <ProgressBar type="circle" value={50} aria-label="Uploading assets">
        <ProgressBar.Value />
        <ProgressBar.Track />
      </ProgressBar>
    </div>
  );
}

Statuses

Default shows progress that is still running. Switch to success once the task completes and to error when it fails, and say in the description what happened and what to do next. The description takes its colour from the bar, and success and error add an icon to it, so colour is not the only signal.

tsx
import { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';

const states = [
  { status: 'default', value: 50, description: '9 of 18 files uploaded' },
  { status: 'success', value: 100, description: 'All 18 files uploaded' },
  { status: 'error', value: 50, description: 'Upload stopped: 9 files failed. Try again.' },
] as const;

export default function ProgressBarStatuses() {
  return (
    <div className="gap-ws-12 flex w-[20rem] max-w-full flex-col">
      {states.map(({ status, value, description }) => (
        <ProgressBar key={status} status={status} value={value}>
          <ProgressBar.Header>
            <ProgressBar.Label>Uploading assets</ProgressBar.Label>
            <ProgressBar.Value />
          </ProgressBar.Header>
          <ProgressBar.Track />
          <ProgressBar.Description>{description}</ProgressBar.Description>
        </ProgressBar>
      ))}
    </div>
  );
}

Composition

Compose the parts to change what the bar shows. Give ProgressBar.Value children to show a count instead of the percentage, and set max on the root so the fill and the screen reader value follow it. The label names the progressbar and the description describes it. Without children the bar and the circle render only their track, so compose ProgressBar.Value for the percentage.

tsx
import { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';

export default function ProgressBarComposition() {
  const uploaded = 32;
  const total = 40;

  return (
    <div className="gap-ws-12 flex w-[20rem] max-w-full flex-col">
      <ProgressBar value={uploaded} max={total}>
        <ProgressBar.Header>
          <ProgressBar.Label>Uploading files</ProgressBar.Label>
          <ProgressBar.Value>
            {uploaded} / {total}
          </ProgressBar.Value>
        </ProgressBar.Header>
        <ProgressBar.Track />
        <ProgressBar.Description>{total - uploaded} files remaining</ProgressBar.Description>
      </ProgressBar>
      <div className="gap-ws-5 flex items-center justify-between">
        <span className="typography-label-sm text-ws-static-base">Syncing library</span>
        <ProgressBar type="circle" value={80} aria-label="Syncing library">
          <ProgressBar.Value />
          <ProgressBar.Track />
        </ProgressBar>
      </div>
    </div>
  );
}

API reference

ProgressBar

NameDescriptionDefault
asChild

Renders the root onto its single child element, which then holds the parts, e.g. `<ProgressBar asChild><section>…</section></ProgressBar>`. Without one, the root stays a `<div>`.

boolean
—
children

The parts to render: `ProgressBar.Header`, `.Label`, `.Value`, `.Track`, `.Description`. Without children both types render only their track: the bar, or the ring.

ReactNode
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
max

The value that means complete. Defaults to `100`.

number
—
status

State of the task: `default` while it runs, `success` when it finished, `error` when it failed. Sets the colour of the fill, the circle's icon and the description.

ProgressBarStatus
'default'
type

Shape of the progress indicator: a full-width bar or a compact ring.

ProgressBarType
'bar'
value

Current progress, clamped between `0` and `max`. A missing or `NaN` value renders `0`.

number
—
Every other prop of Radix Progress.Root is passed through to it. See Radix Progress.Root.

ProgressBar.Description

No props of its ownIt takes its content as children.
Every other prop of <span> is passed through to it. See MDN: <span>.

ProgressBar.Header

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

ProgressBar.Label

NameDescriptionDefault
children

Label content: plain text or rich content such as formatted text.

ReactNode
—
Every other prop of <label> is passed through to it. See MDN: <label>.

ProgressBar.Track

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

ProgressBar.Value

NameDescriptionDefault
children

Fixed content that replaces the computed value; wins over `formatValue`. Visual only.

ReactNode
—
formatValue

Builds the text from the clamped value and `max`, e.g. `(value, max) => \`${value} / ${max}\``. Visual only: screen readers hear the percentage, or the root's `aria-valuetext` when you set it.

((value: number, max: number) => ReactNode)
—
Every other prop of <span> is passed through to it. See MDN: <span>.

Accessibility

  • Both types render role="progressbar" with the value on the root.
  • Name it: ProgressBar.Label on a bar; aria-label on a circle. Without either, the name falls back to “Progress”. ProgressBar.Description describes it.
  • ProgressBar.Value text (formatValue or children) is visual only. Screen readers hear the percentage; set aria-valuetext on the root when the shown value means something else.
  • Success and error add an icon, so colour is not the only signal.
PartRendersDescription
ProgressBarRadix Progress.RootShows how far a task has got, as a bar or a ring.
ProgressBar.Description<span>Helper text below the bar, coloured by the root `status`; it describes the progressbar.
ProgressBar.Header<div>The row above the bar holding `ProgressBar.Label` and `ProgressBar.Value` (bar type).
ProgressBar.Label<label>The visible label; it names the progressbar through `aria-labelledby`.
ProgressBar.Track<div>The bar's track and fill, or the ring (an icon on success and error) for the circle type.
ProgressBar.Value<span>The value as text, the percentage by default.
65%
12 of 18 files uploaded
tsx
import { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';

<ProgressBar value={65}>
  <ProgressBar.Header>
    <ProgressBar.Label>Uploading assets</ProgressBar.Label>
    <ProgressBar.Value />
  </ProgressBar.Header>
  <ProgressBar.Track />
  <ProgressBar.Description>12 of 18 files uploaded</ProgressBar.Description>
</ProgressBar>

Appearance

Type
Status

Content

Value
Text