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
| Variant | Parts | Moving (motion-safe) | Still (reduced motion) |
|---|---|---|---|
spinner | the button's 3/4 arc | animate-spin | a dashed ring (the progress circle's) |
dots | three 22% dots | loader-dots: each fades and lifts in turn, 1.2 s | opacities 0.3, 0.6, 1 |
bars | three bars | loader-bars: each grows on Y in turn, 1 s | heights 50%, 100%, 70% |
pulse | a 40% dot, a ring | loader-pulse: the ring grows from the dot and fades, 1.4 s | the ring at full size, 0.3 |
morph | one 62% shape | loader-morph: square, circle, rounded square, square, turning 120° each step, 2.4 s | the 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
| Role | status (polite live region) |
| Name / content | label, visually hidden; the drawing is aria-hidden |
| Keyboard | none: not focusable |
| Motion | motion-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'sloadingdraws 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.