components / feedback
Progress
A bar that shows how far a task has come, or that it is still working.
465 B gzip client componentbase ui · progress
progress-default.tsx
"use client";
import { useEffect, useState } from "react";
import { Progress, ProgressLabel, ProgressValue } from "@/components/ui/progress";
export default function ProgressDefault() {
const [value, setValue] = useState(20);
useEffect(() => {
const id = setInterval(() => setValue((v) => (v >= 100 ? 0 : Math.min(100, v + 10))), 1200);
return () => clearInterval(id);
}, []);
return (
<div className="flex w-full max-w-xs flex-col gap-6">
<Progress value={value}>
<div className="flex items-center justify-between">
<ProgressLabel>Uploading</ProgressLabel>
<ProgressValue />
</div>
</Progress>
<Progress aria-label="Loading" value={null} />
</div>
);
}Installation
$ npx shadcn@latest add https://cd-ui.vercel.app/r/progress.jsonfirst time? set up components.json and the theme first: see installation.
Usage
import { Progress, ProgressLabel, ProgressValue } from "@/components/ui/progress"
<Progress value={60}>
<ProgressLabel>Uploading</ProgressLabel>
<ProgressValue />
</Progress>API
Progress
Base UI · Progress.RootBar from 0 to 100. The fill moves in 240ms. With a null value it becomes indeterminate.
| prop | type | default |
|---|---|---|
valueCurrent progress, or | number | null | - |
min · maxLimits of the scale. | number | 0 · 100 |
classNameExtra classes, merged with | string | - |
ProgressLabel · ProgressValue
Base UI · Progress.Label · Progress.ValueProgressLabel names the bar and ProgressValue shows the percentage.
| prop | type | default |
|---|---|---|
classNameExtra classes, merged with | string | - |
Accessibility
- It has
role="progressbar"witharia-valuenow. Always name it withProgressLabeloraria-label.