How it works
Every variant draws from one box and scales its strokes from it, so sizes never look heavier or lighter than each other. The ring is a conic gradient masked to a band, with a round cap on the leading end and a tail that fades into a faint track; it turns on an ease-in-out curve so it feels driven rather than mechanical.
Use it for
- Waits of about 300ms to a few seconds where the length is unknown.
- Inside buttons, chips and rows to show that one item is busy.
Look elsewhere when
- Known progress: show a progress bar or ring with a value.
- Loading a whole layout: use skeletons that match the content.
- Waits under 300ms: show nothing, to avoid a flash.
Usage
import { Spinner } from './Spinner.jsx'
export function SaveButton({ saving }) {
return (
<button aria-busy={saving}>
{saving ? <Spinner size="sm" label="Saving" /> : null}
{saving ? 'Saving' : 'Save'}
</button>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
variant | 'ring' | 'dots' | 'bars' | 'pulse' | 'ring' | Which mark. ring for general waits, dots for chat or inline text, bars for audio or live data, pulse for background sync. |
size | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number | 'md' | 14 / 18 / 24 / 32 / 44 px, or any number of px. Strokes scale with it. |
speed | number | 1 | Multiplies the speed of every variant. |
label | string | 'Loading' | Announced text, visually hidden. |
...rest | HTMLAttributes<HTMLSpanElement> | — | Passed to the root. Set color (or the parent's) to tint it. |
Accessibility
- The root is role="status" with a visually hidden label, so the wait is announced once; the drawing is aria-hidden.
- When the spinner sits in a button, also set aria-busy on the button and keep its text.
- Reduced motion stops all rotation, travel and ripples; the mark only fades slowly in place.
Motion
Ring: one turn per 900ms on cubic-bezier(0.45, 0.15, 0.4, 0.9). Dots: 1100ms swell, staggered by 180ms. Bars: 1000ms rise, staggered by 150ms. Pulse: 1400ms breath with two ripples half a cycle apart. All divide by speed.
Add it to your project
Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.
Spinner.jsxspinner.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.



