Refresh Icon
shadcn-extras/refresh-iconFreeComponent
Animated refresh/sync icon with spin and pulse effects.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/NayanDevLab/shadcn-extras/dev/public/c/refresh-icon.jsonSource
1'use client';23import { motion, useAnimation } from 'motion/react';4import { RefreshCcw } from 'lucide-react';5import { cn } from '@/lib/utils';6import { useEffect, useState } from 'react';78interface RefreshIconProps {9 className?: string;10 color?: string;11 size?: number;12 isRefreshing?: boolean;13 startOnHover?: boolean;14 animationType?: 'spin' | 'pulse';15}1617export function RefreshIcon({18 className,19 color = 'currentColor',20 size = 24,21 isRefreshing = false,22 startOnHover = true,23 animationType = 'spin',24}: RefreshIconProps) {25 const controls = useAnimation();26 const [isHovered, setIsHovered] = useState(false);27 const shouldAnimate = isRefreshing || (startOnHover && isHovered);2829 useEffect(() => {30 if (shouldAnimate) {31 if (animationType === 'spin') {32 controls.start({33 rotate: 360,34 transition: {35 duration: 1,36 repeat: Infinity,37 repeatType: 'loop',38 ease: 'linear',39 },40 });41 } else if (animationType === 'pulse') {42 controls.start({43 scale: [1, 1.1, 1],44 opacity: [1, 0.7, 1],45 transition: {46 duration: 1.5,47 repeat: Infinity,48 repeatType: 'loop',49 ease: 'easeInOut',50 },51 });52 }53 } else {54 controls.stop();55 if (animationType === 'spin') {56 controls.set({ rotate: 0 });57 } else {58 controls.set({ scale: 1, opacity: 1 });59 }60 }61 }, [shouldAnimate, animationType, controls]);6263 return (64 <div65 className={cn(66 'relative flex cursor-pointer items-center justify-center select-none',67 className68 )}69 onMouseEnter={() => setIsHovered(true)}70 onMouseLeave={() => setIsHovered(false)}71 >72 <motion.div animate={controls}>73 <RefreshCcw size={size} color={color} />74 </motion.div>75 </div>76 );77}
What it pulls in
npm packages
Files it writes
More from shadcn-extras
All 33 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Image Gridanimated-image-grid | shadcn-extras | Components | Free | no deps · 3 files | |
| Blog Card Fourblog-card-four | shadcn-extras | Components | Free | 1 dep | |
| Blog Card Oneblog-card-one | shadcn-extras | Components | Free | no deps | |
| Blog Card Threeblog-card-three | shadcn-extras | Components | Free | 1 dep | |
| Blog Card Twoblog-card-two | shadcn-extras | Components | Free | 1 dep | |
| Bulb Iconbulb-icon | shadcn-extras | Components | Free | 2 deps | |
| Chevron Stepschevron-steps | shadcn-extras | Components | Free | no deps | |
| Circular Gallerycircular-gallery | shadcn-extras | Components | Free | no deps · 3 files |
