ui icon indicating copy to clipboard operation
ui copied to clipboard

Circular Progress Indicator

Open sonigeez opened this issue 1 year ago • 30 comments

why we don't have any circular progress indicator in library?

sonigeez avatar Jun 24 '23 17:06 sonigeez

This can be easily done with tailwind animate-spin;

// Icon.tsx

import {Loader2} from 'lucide-react';

export const Icons = {
  spinner: Loader2,
};

// Usage
<Icons.spinner className="h-4 w-4 animate-spin" />

chungweileong94 avatar Jun 25 '23 05:06 chungweileong94

I think they meant something like this, where you can have a specific progress % rather than a general spinner:

image

AnandChowdhary avatar Jul 18 '23 14:07 AnandChowdhary

@sonigeez , @AnandChowdhary provided more context. I think everyone meant the above.

adaboese avatar Nov 01 '23 02:11 adaboese

@sonigeez @AnandChowdhary any chance this will get picked up again?

xpluscal avatar Jan 26 '24 04:01 xpluscal

+1

kailingding avatar Mar 11 '24 06:03 kailingding

+1 was also looking for this

navkuun avatar Mar 14 '24 07:03 navkuun

+1

17Amir17 avatar Mar 14 '24 08:03 17Amir17

Screenshot 2024-03-19 at 2 24 26 PM looking for circular progress

mahmudulnayeem avatar Mar 19 '24 08:03 mahmudulnayeem

+1

sgiovo avatar Mar 20 '24 17:03 sgiovo

+1

Kiro369 avatar Mar 21 '24 23:03 Kiro369

+1

Kathenae avatar Mar 25 '24 13:03 Kathenae

+1

BertVanHecke avatar Mar 26 '24 15:03 BertVanHecke

This would be a great addition

shahnewaz-labib avatar Mar 27 '24 11:03 shahnewaz-labib

+1

ialmanzaj avatar Apr 07 '24 18:04 ialmanzaj

+1

HarshDev2 avatar Apr 14 '24 09:04 HarshDev2

+1

nparashar150 avatar Apr 14 '24 18:04 nparashar150

+1

gustavo-fior avatar Apr 18 '24 19:04 gustavo-fior

+1

flkrnr avatar Apr 30 '24 11:04 flkrnr

+1

Syntarex avatar May 03 '24 23:05 Syntarex

+1

sabin-thapa avatar May 06 '24 04:05 sabin-thapa

+1

1337Impact avatar May 07 '24 22:05 1337Impact

+1 for Radial progress

image

gajakannan avatar May 09 '24 00:05 gajakannan

+1

thallysondias avatar May 09 '24 17:05 thallysondias

+1

mjurincic avatar May 13 '24 20:05 mjurincic

+1

ericaig avatar May 21 '24 09:05 ericaig

+1

serhii-kucherenko avatar May 23 '24 05:05 serhii-kucherenko

+1

christianblandford avatar May 31 '24 02:05 christianblandford

+1

SkyNotBlueEnough avatar Jun 04 '24 18:06 SkyNotBlueEnough

Paste this code into progress.tsx and utilize CircleProgress.

export const CircleProgress = React.forwardRef<
  React.ElementRef<typeof ProgressPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
>(({ className, value, ...props }, ref) => (
  <ProgressPrimitive.Root
    ref={ref}
    className={cn(
      `relative h-20 w-20 overflow-hidden rounded-full bg-primary/20 flex justify-center items-center`,
      className
    )}
    {...props}
    style={{ background: `radial-gradient(closest-side, white 79%, transparent 80% 100%), conic-gradient(green ${(value || 0)}%, pink 0)` }}
  >
    <div className="">{`${(value || 0)}%`}</div>

  </ProgressPrimitive.Root>
))

image

Ritik1330 avatar Jun 05 '24 17:06 Ritik1330

this is my solution

import { motion } from 'framer-motion';
type Props = {
  value: number;
};

export default function CircleProgress({ value }: Props) {
  const percentage = Math.min(Math.max(value, 0), 100);
  const width = 216;
  const radius = 98;

  const circumference = 2 * Math.PI * radius;

  const offset = circumference - (percentage / 100) * circumference;
  return (
    <svg width={width} height={width} xmlns="http://www.w3.org/2000/svg">
      <defs>
        <radialGradient
          id="circle-progress"
          cx="0"
          cy="0"
          r="1"
          gradientUnits="userSpaceOnUse"
          gradientTransform="translate(53.1659 -18.1884) rotate(51.1683) scale(267.012 282.957)"
        >
          <stop stopColor="#F05F84" />
          <stop offset="1" stopColor="#FD312E" />
        </radialGradient>
      </defs>
      <circle
        cx={width / 2}
        cy={width / 2}
        r={radius}
        strokeLinecap="round"
        className="fill-none stroke-neutral-300 stroke-[20px]"
        style={{
          strokeDasharray: circumference,
          strokeDashoffset: circumference,
        }}
      />

      <motion.circle
        cx={'108'}
        cy={'108'}
        r="98"
        strokeLinecap="round"
        className="fill-none stroke-[url('#circle-progress')] stroke-[20px]"
        initial={{
          strokeDashoffset: circumference,
          strokeDasharray: circumference,
        }}
        animate={{ strokeDashoffset: offset }}
        transition={{
          stiffness: 260,
          damping: 20,
          delay: 0.5,
          duration: 1,
          ease: 'easeOut',
        }}
      />
    </svg>
  );
}

nambui98 avatar Jun 28 '24 08:06 nambui98