opensourceui
GitHubTwitter/X
  1. Home
  2. Components
  3. Others
  4. Progress Ring
Back to Others

Components / Others

Progress Ring

Free Others React component — ProgressRingCard. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.

Animated SVG ring with percentage label and clickable stage rows below. Defaults to Design/Development/Testing — pass your own milestones.

Preview

Project Progress

0%Complete

Setup

How to use

Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.

  1. 1

    Run in your terminal:

    $npm install clsx tailwind-merge lucide-react
  2. 2

    Copy lib/cn.ts below. Skip if you already have cn().

  3. 3

    Copy the code below and create components/others/progress-ring-card.tsx in your project.

  4. 4

    Import and render:

    Example

    import { ProgressRingCard } from "@/components/others/progress-ring-card";

    <ProgressRingCard />

lib/cn.ts

1
2
3
4
5
6
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

components/others/progress-ring-card.tsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
"use client";
 
import {
forwardRef,
useEffect,
useId,
useMemo,
useState,
type ComponentPropsWithoutRef,
} from "react";
 
import { cn } from "@/lib/cn";
 
export type ProgressStage = {
label: string;
value: number;
color?: string;
};
 
export type ProgressRingCardProps = Readonly<
{
title?: string;
progress?: number;
progressLabel?: string;
showPercentage?: boolean;
ringStartColor?: string;
ringEndColor?: string;
stages?: ProgressStage[];
animateOnMount?: boolean;
onStageClick?: (stage: ProgressStage, index: number) => void;
} & ComponentPropsWithoutRef<"div">
>;
 
const RADIUS = 40;
const STROKE_WIDTH = 6;
 
// Production-ready Progress Ring component — styled with Tailwind CSS.
export const ProgressRingCard = forwardRef<
HTMLDivElement,
ProgressRingCardProps
>(
(
{
className,
title = "Project Progress",
progress = 73,
progressLabel = "Complete",
showPercentage = true,
ringStartColor = "#14b8a6",
ringEndColor = "#06b6d4",
stages = [
{ label: "Design", value: 100, color: "bg-emerald-500" },
{ label: "Development", value: 73, color: "bg-teal-500" },
{ label: "Testing", value: 30, color: "bg-neutral-200" },
],
animateOnMount = true,
onStageClick,
...props
},
ref,
) => {
const gradientId = useId();
const [displayProgress, setDisplayProgress] = useState(
animateOnMount ? 0 : progress,
);
const [activeStage, setActiveStage] = useState<number | null>(null);
 
const normalizedProgress = useMemo(
() => Math.min(100, Math.max(0, progress)),
[progress],
);
 
const normalizedStages = useMemo(
() =>
stages.map((stage) => ({
...stage,
value: Math.min(100, Math.max(0, stage.value)),
})),
[stages],
);
 
const circumference = useMemo(() => 2 * Math.PI * RADIUS, []);
 
const offset = useMemo(
() => circumference - (displayProgress / 100) * circumference,
[circumference, displayProgress],
);
 
useEffect(() => {
if (!animateOnMount) {
setDisplayProgress(normalizedProgress);
return;
}
 
const start = performance.now();
const duration = 900;
 
const frame = (time: number) => {
const t = Math.min(1, (time - start) / duration);
const eased = 1 - (1 - t) ** 3;
setDisplayProgress(Math.round(normalizedProgress * eased));
if (t < 1) requestAnimationFrame(frame);
};
 
const raf = requestAnimationFrame(frame);
return () => cancelAnimationFrame(raf);
}, [animateOnMount, normalizedProgress]);
 
const handleStageClick = (stage: ProgressStage, index: number) => {
setActiveStage(index);
setDisplayProgress(stage.value);
onStageClick?.(stage, index);
};
 
return (
<div
ref={ref}
data-slot="progress-ring-card"
className={cn(
"w-64 rounded-2xl border border-neutral-100 bg-white p-5 font-sans shadow-lg",
className,
)}
{...props}
>
<p
data-slot="progress-ring-card-title"
className="mb-4 font-mono text-[10px] tracking-widest text-neutral-400 uppercase"
>
{title}
</p>
 
<div
data-slot="progress-ring-card-ring"
className="relative mx-auto mb-4 h-28 w-28"
>
<svg
role="img"
aria-label={`${displayProgress}% ${progressLabel}`}
viewBox="0 0 100 100"
className="h-full w-full -rotate-90"
>
<circle
cx="50"
cy="50"
r={RADIUS}
fill="none"
stroke="#f5f5f5"
strokeWidth={STROKE_WIDTH}
/>
<circle
cx="50"
cy="50"
r={RADIUS}
fill="none"
stroke={`url(#${gradientId})`}
strokeWidth={STROKE_WIDTH}
strokeLinecap="round"
strokeDasharray={circumference}
strokeDashoffset={offset}
className="transition-[stroke-dashoffset] duration-700 ease-out"
/>
<defs>
<linearGradient id={gradientId} x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stopColor={ringStartColor} />
<stop offset="100%" stopColor={ringEndColor} />
</linearGradient>
</defs>
</svg>
 
<div className="absolute inset-0 flex flex-col items-center justify-center">
{showPercentage && (
<span className="text-2xl font-light text-neutral-900">
{displayProgress}%
</span>
)}
<span className="font-mono text-[9px] text-neutral-400">
{progressLabel}
</span>
</div>
</div>
 
<div data-slot="progress-ring-card-breakdown" className="space-y-2">
{normalizedStages.map((stage, index) => (
<button
key={stage.label}
type="button"
onClick={() => handleStageClick(stage, index)}
data-slot="progress-ring-card-stage"
className={cn(
"flex w-full cursor-pointer items-center gap-2 rounded-lg px-1 py-0.5 text-left transition-colors hover:bg-neutral-50",
activeStage === index && "bg-teal-50",
)}
>
<span className="w-16 text-[10px] text-neutral-500">
{stage.label}
</span>
<div className="h-1.5 flex-1 overflow-hidden rounded-full bg-neutral-100">
<div
className={cn(
"h-full rounded-full transition-all duration-500",
stage.color ?? "bg-teal-500",
)}
style={{ width: `${stage.value}%` }}
/>
</div>
<span className="w-6 text-right font-mono text-[10px] text-neutral-400">
{stage.value}%
</span>
</button>
))}
</div>
</div>
);
},
);
 
ProgressRingCard.displayName = "ProgressRingCard";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/others/progress-ring-card.tsx

Sponsor spot · demo preview

Logo

Your brand name

Your tagline or category

A short pitch about your product or service goes here. This is a preview of how sponsor cards will look in this sidebar.

Your call to action

This slot is available. Sponsor Opensource UI and reach developers browsing components every day.