$npx @dinachi/cli@latest add progress
Uploading...75%
x
valuemaxProgressLabelProgressValueupload-progress.tsx
import { Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue } from "@/components/ui/progress"
export function UploadProgress() {
return (
<Progress value={75} className="w-full max-w-sm">
<div className="flex items-center justify-between">
<ProgressLabel>Uploading...</ProgressLabel>
<ProgressValue />
</div>
<ProgressTrack>
<ProgressIndicator />
</ProgressTrack>
</Progress>
)
}Usage
import {
Progress,
ProgressIndicator,
ProgressLabel,
ProgressTrack,
ProgressValue,
} from "@/components/ui/progress"
export function UploadProgress() {
return (
<Progress value={40}>
<ProgressLabel>Upload</ProgressLabel>
<ProgressValue />
<ProgressTrack>
<ProgressIndicator />
</ProgressTrack>
</Progress>
)
}Examples
Uploading...75%
x
A label and the formatted value.
import { Progress, ProgressTrack, ProgressIndicator, ProgressLabel, ProgressValue } from '@/components/ui/progress';
export function Example() {
return (
<Progress value={75} className="w-full max-w-sm">
<div className="flex items-center justify-between">
<ProgressLabel>Uploading...</ProgressLabel>
<ProgressValue />
</div>
<ProgressTrack>
<ProgressIndicator />
</ProgressTrack>
</Progress>
);
}x
A bar at 60 percent.
import { Progress, ProgressTrack, ProgressIndicator } from '@/components/ui/progress';
export function Example() {
return (
<Progress value={60} className="w-full max-w-sm">
<ProgressTrack>
<ProgressIndicator />
</ProgressTrack>
</Progress>
);
}Loading0%
x
The bar eases between values.
import React from 'react';
import { Progress, ProgressTrack, ProgressIndicator, ProgressLabel } from '@/components/ui/progress';
export function Example() {
const [progress, setProgress] = React.useState(0);
React.useEffect(() => {
const timer = setInterval(() => {
setProgress((prev) => {
if (prev >= 100) return 0;
return prev + 10;
});
}, 800);
return () => clearInterval(timer);
}, []);
return (
<Progress value={progress} className="w-full max-w-sm">
<div className="flex items-center justify-between">
<ProgressLabel>Loading</ProgressLabel>
<span className="text-xs text-muted-foreground">{progress}%</span>
</div>
<ProgressTrack>
<ProgressIndicator />
</ProgressTrack>
</Progress>
);
}Notes
Indeterminate
Pass value={null} when the amount of work is unknown. The root then sets data-indeterminate instead of data-progressing or data-complete; style the indicator from these.
Agent
Not registered with the agent bridge; read from the accessibility tree like any progressbar. Listed as progress with value, min and max, and no actions. Indeterminate, it has no value.
agent.snapshot()
// [{ component: "progress", label: "Upload", value: 40, min: 0, max: 100, actions: [] }]API
valuenumber | null
Current value. null makes the bar indeterminate.minnumber = 0
The value at an empty bar.maxnumber = 100
The value at a full bar.formatIntl.NumberFormatOptions
Number format for ProgressValue and the announced text.localeIntl.LocalesArgument
Locale for formatting the value.getAriaValueText(formattedValue, value) => string
Text announced in place of the number.childrenReactNode
Names the progressbar for screen readers and the agent.children(formattedValue, value) => ReactNode
Custom formatting. Both are null while indeterminate.Takes the props of the element it renders.
Takes the props of the element it renders.
Accessibility
- The root is a progressbar with aria-valuenow, aria-valuemin and aria-valuemax.
ProgressLabelnames the bar through aria-labelledby. Without one, pass aria-label on Progress.- Use
getAriaValueTextwhen a percentage is unclear, such as "3 of 10 files". - Reduced motion turns off the indicator's width transition.