Loader

A small busy indicator drawn in CSS: spinner, dots, bars, pulse, morph. No script.

Anatomy

span[role=status][data-ds-loader=variant].inline-flex.text-{tone}
├── the drawing (aria-hidden), size-4 | size-6 | size-10, in currentColor
└── span.sr-only   ← the label
VariantPartsMoving (motion-safe)Still (reduced motion)
spinnerthe button's 3/4 arcanimate-spina dashed ring (the progress circle's)
dotsthree 22% dotsloader-dots: each fades and lifts in turn, 1.2 sopacities 0.3, 0.6, 1
barsthree barsloader-bars: each grows on Y in turn, 1 sheights 50%, 100%, 70%
pulsea 40% dot, a ringloader-pulse: the ring grows from the dot and fades, 1.4 sthe ring at full size, 0.3
morphone 62% shapeloader-morph: square, circle, rounded square, square, turning 120° each step, 2.4 sthe three shapes in a row, fading in order

The keyframes and the four utilities are in theme.css (build-tokens.mjs). The periods are loop lengths, not transition timings, so they are literals beside the progress sweep's 1.5 s, as Tailwind's own spin and pulse are; negative delays start each part mid-cycle. Every still form is a deliberate picture of "busy", never the animation stopped on a frame.

Props

variant (spinner default), size (sm 16px, md 24px default, lg 40px), tone (neutral = fg-muted default, accent, success, warning, danger), label (Loading). Unknown values fall back to the defaults.

Accessibility

Rolestatus (polite live region)
Name / contentlabel, visually hidden; the drawing is aria-hidden
Keyboardnone: not focusable
Motionmotion-safe: only, with a still form for each variant

The host marks the region that is loading aria-busy="true".

Do not

  • Do not put one in a button. ds::button's loading draws the spinner and blocks a second press.
  • Do not use one for work of known length. That is ds::progress.
  • Do not show one instantly. Delay it ~300ms; a flash reads as a glitch.
  • Do not label five loaders "Loading". Say what is loading.

From the package repo: edit this page on GitHub.

Was this page helpful?