Spinner Loader

PreviousNext

Circular spinning loader

Docs
animbitscomponent

Preview

Loading preview…
registry/new-york/animations/loaders/spinner.tsx
"use client";
import * as React from "react";
import { motion, HTMLMotionProps } from "motion/react";
import { cn } from "@/lib/utils";
export interface LoaderSpinnerProps
  extends Omit<HTMLMotionProps<"div">, "children"> {
  size?: number;
  color?: string;
  borderWidth?: number;
  duration?: number;
}
export function LoaderSpinner({
  className,
  size = 40,
  color = "currentColor",
  borderWidth = 4,
  duration = 1,
  ...props
}: LoaderSpinnerProps) {
  return (
    <motion.div
      className={cn("rounded-full", className)}
      style={{
        width: size,
        height: size,
        border: `${borderWidth}px solid transparent`,
        borderTopColor: color,
        borderRightColor: color,
      }}
      animate={{ rotate: 360 }}
      transition={{
        duration,
        ease: "linear",
        repeat: Infinity,
      }}
      {...props}
    />
  );
}

Installation

npx shadcn@latest add @animbits/loaders-spinner

Usage

import { LoadersSpinner } from "@/components/loaders-spinner"
<LoadersSpinner />