Circular progress on SVG. Shows the percentage or your own content in the center, animates the arc when the value changes, switches color by thresholds and has an indeterminate mode for unknown durations.
Preview
Change the value to see the arc move.
Installation
Usage
import { ProgressRing } from "@/components/ui/progress-ring"
export default function Example() {
return <ProgressRing value={64} size={120} thickness={10} label="Upload progress" />
}Examples
Size and thickness
size sets the diameter, thickness the stroke. rounded={false} gives flat ends.
<ProgressRing value={25} size={40} thickness={4} />
<ProgressRing value={50} size={64} thickness={6} />
<ProgressRing value={75} size={96} thickness={12} />
<ProgressRing value={90} size={128} thickness={4} rounded={false} />Color by thresholds
Each threshold applies from its from percentage. Here the ring turns warning at 70% and destructive at 90%.
<ProgressRing
value={usage}
thresholds={[
{ from: 0, color: "var(--primary)" },
{ from: 70, color: "var(--chart-4)" },
{ from: 90, color: "var(--destructive)" },
]}
/>Custom content
Children replace the percentage. max lets you pass the value in your own units.
3/5tasks
<ProgressRing value={done} max={5} size={112} thickness={9}>
<span className="text-2xl">{done}/5</span>
<span className="text-xs text-muted-foreground">tasks</span>
</ProgressRing>Indeterminate
When the duration is unknown, the arc spins and aria-valuenow is omitted.
<ProgressRing indeterminate size={48} thickness={5} label="Loading" />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | 0 | Current value |
| max | number | 100 | Maximum value |
| size | number | 64 | Diameter in px |
| thickness | number | 6 | Stroke width in px |
| indeterminate | boolean | false | Spinning arc without a value |
| thresholds | { from: number; color: string }[] | - | Colors by percentage, the highest matching from wins |
| color | string | "var(--primary)" | Indicator color when no threshold matches |
| showValue | boolean | true | Show the percentage in the center |
| animateValue | boolean | true | Roll the digits of the percentage when the value changes |
| formatValue | (value: number, max: number) => ReactNode | - | Custom formatter for the center value |
| children | ReactNode | - | Custom center content |
| label | string | "Progress" | Accessible name (aria-label) |
| rounded | boolean | true | Round stroke ends |
| trackClassName | string | - | Classes for the track circle |
| indicatorClassName | string | - | Classes for the indicator circle |
| className | string | - | Additional CSS classes |
Features
- Accessible: role="progressbar" with aria-valuenow, aria-valuemin and aria-valuemax
- Smooth: the arc animates with a CSS transition, turned off for reduced motion
- Theme colors: the track uses muted, the indicator primary, thresholds take any CSS color
- Server friendly: no client hooks, works in server components