progress-demo.tsx
progress.tsx
prompt.md
Collapse
Reset
Copy Code
Download
Run
1
"use client";
2
3
import { useEffect, useState } from "react"
4
import { Progress } from "./progress"
5
6
export function ProgressDemo() {
7
const [progress, setProgress] = useState(0)
8
9
useEffect(() => {
10
// Initial delay then animate
11
const timer = setTimeout(() => setProgress(66), 500)
12
13
// Looping animation for demo purposes
14
const interval = setInterval(() => {
15
setProgress((v) => (v >= 100 ? 0 : v + 33))
16
}, 2000)
17
18
return () => {
19
clearTimeout(timer)
20
clearInterval(interval)
21
}
22
}, [])
23
24
return (
25
<div className="flex items-center justify-center min-h-[400px] bg-zinc-50 dark:bg-black p-8">
26
<div className="w-full max-w-[200px]">
27
<Progress value={progress} />
28
</div>
29
</div>
30
)
31
}
32

