Cómo funciona
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.
Úsalo para
- 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.
Busca otra opción cuando
- 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.
Uso
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>
)
}Propiedades
| Propiedad | Tipo | Por defecto | Qué hace |
|---|---|---|---|
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. |
Accesibilidad
- 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.
Movimiento
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.
Añádelo a tu proyecto
Copia la instrucción en Codex o Claude Code. El agente lee el código publicado, te muestra lo que va a escribir y añade el componente junto a los tuyos.
Spinner.jsxspinner.csstokens.cssREADME.md
Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.



