Loader
A small busy indicator drawn in CSS: the button's spinner, three dots, three bars, a pulse, or a shape that turns from square to circle and back.

No script. Every variant is CSS animation behind motion-safe:.
Use it
<x-ds::loader />
<x-ds::loader variant="dots" size="sm" />
<x-ds::loader variant="bars" tone="accent" label="Uploading photos" />
Beside words, at the text's size:
<span class="inline-flex items-center gap-2">
<x-ds::loader size="sm" /> Loading your reports
</span>
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
variant | spinner dots bars pulse morph | spinner | Which drawing. |
size | sm md lg | md | 16, 24 or 40px square. |
tone | neutral accent success warning danger | neutral | Its colour; neutral is the muted text colour. |
label | string | Loading | What is loading, read by a screen reader and never shown. |
Which one
spinneris the one already in button'sloading. Use it wherever a reader has seen the system's spinner before.dotsandbarsare quieter, for a line of text or a chat reply.pulseis for something live: a connection, a recording.morphis decoration with a job: a long, single wait on an otherwise empty screen.
If you know how far along the work is, use progress instead: a bar that fills says more than any loader.
Motion
With reduced motion nothing moves, and none of them is a frame stopped halfway: the spinner becomes a dashed ring, the dots sit at three strengths, the bars at three heights, the pulse is a dot with a faint ring, and the morph shows the three shapes it would pass through in a row. Each still reads as busy. (The documentation image above is a frame of each animation, the morph at its square.)
Accessibility
- It is
role="status", with itslabelas text for screen readers only; the drawing isaria-hidden. A loader that appears after the page has loaded is announced by its words. - Name what is loading when there is more than one thing: "Loading comments" is useful, five "Loading"s are not.
- Mark the region that is loading
aria-busy="true"as well, and remove it when the content arrives. Skeleton swap does this for you.
Don't
- Don't show one for under ~300ms. A flash of a spinner reads as a glitch; delay it.
- Don't put one in a button. Use the button's
loading, which also blocks a second press. - Don't use one for work with a known length. That is progress.
- Don't stack variants for variety. One loader per screen, the same one every time.
More in specs/loader.md.
From the package repo: edit this page on GitHub.