Spin Loader
Free Loaders React component — SpinLoader. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.
Minimal spinning loader built on a lucide icon — defaults to Loader, but pass any icon prop. Sizes: sm, md, lg.
Preview
Setup
How to use
Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.
- 1
Run in your terminal:
$npm install clsx tailwind-merge lucide-react - 2
Copy
lib/cn.tsbelow. Skip if you already havecn(). - 3
Copy the code below and create
components/loaders/spin-loader.tsxin your project. - 4
Import and render:
Exampleimport { SpinLoader } from "@/components/loaders/spin-loader";
lib/cn.ts
import { type ClassValue, clsx } from "clsx";import { twMerge } from "tailwind-merge";export function cn(...inputs: ClassValue[]) {return twMerge(clsx(inputs));}
components/loaders/spin-loader.tsx
import type { LucideIcon } from "lucide-react";import { Loader } from "lucide-react";import { cn } from "@/lib/cn";export type SpinLoaderSize = "sm" | "md" | "lg";export type SpinLoaderProps = Readonly<{size?: SpinLoaderSize;icon?: LucideIcon;label?: string;className?: string;iconClassName?: string;}>;const SIZE: Record<SpinLoaderSize, number> = {sm: 18,md: 24,lg: 32,};export function SpinLoader({size = "md",icon: Icon = Loader,label = "Loading",className,iconClassName,}: SpinLoaderProps) {const iconSize = SIZE[size];return (<divdata-slot="spin-loader"data-size={size}className={cn("inline-flex items-center justify-center", className)}role="status"aria-live="polite"aria-label={label}><Iconsize={iconSize}strokeWidth={2}className={cn("animate-spin text-neutral-900 motion-reduce:animate-none",iconClassName,)}aria-hidden/></div>);}