Baktiyar Ablaikhan

Animated Circular Progress Bar

Source
Magic UI ↗
Author
Magic UI
Licence
MIT

Loading…

A gauge ring that eases to a new value every two seconds.

Code

"use client";

import { useEffect, useState } from "react";

import { AnimatedCircularProgressBar } from "@/lab/magicui/ui/animated-circular-progress-bar";

export default function AnimatedCircularProgressBarDemo() {
  const [value, setValue] = useState(0);

  useEffect(() => {
    const handleIncrement = (prev: number) => (prev === 100 ? 0 : prev + 10);
    const first = setTimeout(() => setValue(handleIncrement), 100);
    const interval = setInterval(() => setValue(handleIncrement), 2000);
    return () => {
      clearTimeout(first);
      clearInterval(interval);
    };
  }, []);

  return (
    <div className="relative flex h-full w-full items-center justify-center text-neutral-950">
      <AnimatedCircularProgressBar
        value={value}
        gaugePrimaryColor="rgb(79 70 229)"
        gaugeSecondaryColor="rgba(0, 0, 0, 0.1)"
      />
    </div>
  );
}
Prompt

Build "Animated Circular Progress Bar", a loader animation. What it does: A gauge ring that eases to a new value every two seconds. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS. Technique: inline SVG. It sits on a light background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://magicui.design/docs/components/animated-circular-progress-bar (Magic UI, MIT).