Spin Icon

PreviousNext

Continuous rotation animation for icons

Docs
animbitscomponent

Preview

Loading preview…
registry/new-york/animations/icons/spin.tsx
"use client";
import * as motion from "framer-motion/client";
import type { HTMLMotionProps } from "motion/react";
interface SpinIconProps extends Omit<HTMLMotionProps<"div">, "animate"> {
  children: React.ReactNode;
  duration?: number;
  direction?: "clockwise" | "counterclockwise";
}
export function SpinIcon({
  children,
  duration = 1,
  direction = "clockwise",
  ...props
}: SpinIconProps) {
  const rotation = direction === "clockwise" ? 360 : -360;
  return (
    <motion.div
      animate={{ rotate: rotation }}
      transition={{
        duration,
        ease: "linear",
        repeat: Infinity,
      }}
      {...props}
    >
      {children}
    </motion.div>
  );
}

Installation

npx shadcn@latest add @animbits/icons-spin

Usage

import { IconsSpin } from "@/components/icons-spin"
<IconsSpin />