Spinner
abui/spinnerFreeComponent
A customizable loading spinner component with size, speed, and color variants.
Live preview
live · rendered by the registry
Rendered by abui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://abui.io/r/spinner.jsonSource
1import * as React from "react"2import { cva, type VariantProps } from "class-variance-authority"34import { cn } from "@/lib/utils"56const spinnerVariants = cva("animate-spin", {7 variants: {8 size: {9 sm: "size-4",10 default: "size-6",11 lg: "size-8",12 xl: "size-12",13 },14 speed: {15 slow: "[animation-duration:1200ms]",16 default: "[animation-duration:900ms]",17 fast: "[animation-duration:600ms]",18 },19 },20 defaultVariants: {21 size: "default",22 speed: "default",23 },24})2526export interface SpinnerProps27 extends Omit<React.ComponentProps<"svg">, "size" | "speed">,28 VariantProps<typeof spinnerVariants> {29 /**30 * Stroke width of the spinner arc31 * @default 332 */33 strokeWidth?: number34 /**35 * CSS class for the background circle36 * @default "stroke-muted-foreground/20"37 */38 bgClassName?: string39}4041const Spinner = React.forwardRef<SVGSVGElement, SpinnerProps>(42 ({ className, size, speed, strokeWidth = 3, bgClassName = "stroke-muted-foreground/20", ...props }, ref) => {43 return (44 <svg45 ref={ref}46 className={cn(spinnerVariants({ size, speed }), "text-foreground", className)}47 viewBox="0 0 42 42"48 {...props}49 >50 <g fill="none" transform="translate(3 3)" strokeWidth={strokeWidth}>51 <circle className={bgClassName} cx="18" cy="18" r="18" />52 <path53 className="stroke-current"54 stroke="currentColor"55 d="M36 18c0-9.94-8.06-18-18-18"56 strokeLinecap="round"57 strokeLinejoin="round"58 />59 </g>60 </svg>61 )62 },63)6465Spinner.displayName = "Spinner"6667export { Spinner, spinnerVariants }
What it pulls in
npm packages
Files it writes
More from abui
All 20 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordion Multiselectaccordion-multiselect | abui | Components | Free | 3 deps | |
| Breakpoint Displaybreakpoint-display | abui | Components | Free | no deps | |
| Color Swatch Selectorcolor-swatch-selector | abui | Components | Free | no deps | |
| Label Selectorlabel-selector | abui | Components | Free | 2 deps | |
| Radio Rowsradio-rows | abui | Components | Free | no deps | |
| Radio Tabsradio-tabs | abui | Components | Free | no deps | |
| Scroll Progressscroll-progress | abui | Components | Free | 1 dep | |
| Text Gradienttext-gradient | abui | Components | Free | no deps |
