When to use
- A short wait with nothing to measure: saving, signing in, fetching search results.
- Inside a button or beside a label while an action runs.
- A small area that is refreshing, where a skeleton would be too much.
When not to use
Installation
pnpm dlx shadcn add https://eased.dev/r/spinner.jsonnpx shadcn add https://eased.dev/r/spinner.jsonyarn dlx shadcn add https://eased.dev/r/spinner.jsonbunx --bun shadcn add https://eased.dev/r/spinner.jsonThe command adds Spinner, everything it builds on and Eased’s tokens to your project.
Install the dependencies
pnpm add motionnpm install motionyarn add motionbun add motionAdd the Eased pieces it builds on
Copy each item’s files the same way, or install them with the CLI:
Copy the source into your project
components/eased/spinner/spinner.tsxTSX "use client";import { useInView } from "motion/react";import { useRef, type CSSProperties } from "react";export type SpinnerSize = "sm" | "md" | "lg";export type SpinnerProps = { /** * `sm` 14px (beside 12px text), `md` 16px (13–14px text), `lg` 20px (16px text), or a * diameter in px. Default `md`. */ size?: SpinnerSize | number; /** * Announced name, e.g. "Saving". Default "Loading". Pass `false` when visible text beside the * spinner already says what is happening ("Uploading…"), so it is not read twice. */ label?: string | false; /** Colour comes from `currentColor`; set a text colour class here. Default `text-text-muted`. */ className?: string;};const SIZES: Record<SpinnerSize, number> = { sm: 14, md: 16, lg: 20 };/** * A quarter arc turning on a faint ring, the same mark as eased.dev's status badge. It spins * on the compositor, so it keeps turning while the main thread is busy; it pauses off-screen * and freezes in place under reduced motion (R85). */export function Spinner({ size = "md", label = "Loading", className = "text-text-muted" }: SpinnerProps) { const ref = useRef<HTMLSpanElement>(null); const inView = useInView(ref); const px = typeof size === "number" ? size : SIZES[size]; // Ring weight scales with size: 2px at 16, 2.5px at 22 (the status badge), never under 1.5px. const stroke = Math.max(1.5, Math.round(px * 0.114 * 4) / 4); const style = { width: px, height: px, "--spinner-w": `${stroke}px` } as CSSProperties; return ( <span ref={ref} role={label ? "status" : undefined} aria-label={label || undefined} aria-hidden={label ? undefined : true} style={style} className={`relative inline-block shrink-0 align-middle ${className}`} > <span className="absolute inset-0 rounded-pill border-(length:--spinner-w) border-current opacity-15" /> <span className="absolute inset-0 animate-[eased-spin_900ms_linear_infinite] rounded-pill border-(length:--spinner-w) border-transparent border-t-current reduced:animate-none" style={{ animationPlayState: inView ? "running" : "paused" }} /> <style href="eased-spinner" precedence="default"> {"@keyframes eased-spin { to { transform: rotate(360deg); } }"} </style> </span> );}Keep the folder layout
The files import each other by relative path (
../lib/motion), so keep each one at the path shown, undercomponents/eased/.
Usage
import { Spinner } from "@/components/eased/spinner/spinner";export function Saving() { return ( <p className="flex items-center gap-2 text-ui-sm text-text-muted"> <Spinner size="sm" label={false} className="text-current" /> Saving changes… </p> );}Examples
On its own
With no visible text, the default label is announced.
<Spinner label="Loading messages" />Larger or custom sizes
lg sits beside 16px text; a number sets any diameter in px, and the ring's weight scales with it.
<Spinner size="lg" /><Spinner size={32} className="text-brand" />API reference
Spinner
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "md" | "lg" | number | "md" | sm 14px beside 12px text, md 16px beside 13–14px, lg 20px beside 16px, or any diameter in px. |
label | string | false | "Loading" | The announced name. false when visible text beside it already says what is happening. |
className | string | "text-text-muted" | The colour comes from currentColor; set a text colour class here. |
Accessibility
- With a label it is
role="status"named by the label, e.g. "Loading" or "Saving". - With
label={false}it is hidden from assistive tech, so "Saving changes…" beside it is not read twice. - The colour follows the text colour, so the arc keeps the contrast of the text it sits beside.
Motion
One linear turn every 900ms, run by a CSS animation on the compositor, so it keeps spinning while the main thread is busy. It pauses while off-screen. Reduced motion: the arc freezes in place.
Notes for AI
Use Spinner for short, unmeasured waits, size="sm" inside buttons and beside small text. Pass label={false} whenever visible text describes the wait, and a specific label ("Saving") otherwise.
Do not add a spinner to an Eased Button or Search Field yourself: they render this same spinner while loading. Do not set its size with width or height classes; use size, so the ring's weight scales too.
Related components
- Animated Progress Bar: a bar for waits you can measure.
- Skeleton Loader: placeholders that hold the layout.
- Animated Button: renders this spinner while loading.