Spinner
An indicator that shows a loading state.
Installation
Needs the arene setup first.
Install the packages it imports:
Set up the token layer and the StyleX compiler, if you have not already. See Installation.
Paste this source into the file named in its title.
Change the @/ imports if your project uses different aliases.
Usage
The spinner keeps turning under prefers-reduced-motion: reduce, because a
stopped spinner looks like a stalled one.
Variants
default turns a glyph. ring is a ring with one bright head and a tail that
fades behind it. dots lights three dots one after another. All three take the
same size and colour, and all keep moving under reduced motion.
Size
A spinner takes its size from --arene-icon-size, the property a control sets
for its icons, so a spinner inside a small button or a badge shrinks with the
icons beside it. Give a standalone spinner a width and height through
xstyle.
Custom icon
Spread spinnerStyles.base onto any icon to give it the spinner's size and
rotation. Add role="status" and aria-label yourself; only Spinner sets
them for you.
Button
Place the spinner before the label with iconPosition="start", or after it
with iconPosition="end".
Badge
Place the spinner before the label with iconPosition="start", or after it
with iconPosition="end".
Input group
Put the spinner in an InputGroupAddon and position it with the addon's
align.
API reference
Pass render to replace a part's element or compose it with another component.
Spinner renders an <svg> for default and a <span> for ring and
dots, and accepts every attribute of its element. Anything you pass overrides
its own defaults, including role and aria-label.
Spinner
| Prop | Type | Default |
|---|---|---|
variant | "default" | "ring" | "dots" | "default" |
xstyle | StyleXStyles | — |
className | string | — |
role | string | "status" |
aria-label | string | "Loading" |
spinnerStyles
The style map behind the component. Spread it onto any element.
| Key | What it is |
|---|---|
base | The inherited icon size and the rotation |
variants | The ring's mask and the dots' row, by name |
dot | One dot and its blink |
dotDelays | The second and third dots' offsets, in order |
Data attributes
| Attribute | On | Effect |
|---|---|---|
data-slot="spinner" | the spinner | Targets the glyph from a parent |
data-variant | the spinner | Mirrors the variant prop |