Spinner
Shows that something is loading, in place of an icon.
Default
On its own it's 16px and takes the text color.
<.spinner />
Sizes
Small, medium, and large match the 12px, 16px, and 20px icon sizes.
<.spinner size="small" />
<.spinner size="medium" />
<.spinner size="large" />
In badges
In a badge's icon slot it fills the icon's box.
<.badge :for={size <- ~w(small medium large)} label="Running" color="information" size={size}>
<:icon><.spinner /></:icon>
</.badge>
<.badge label="Running" color="focus" style="light-fill" size="large">
<:icon><.spinner /></:icon>
</.badge>
Label
label
names what's loading for screen readers.
<.spinner size="large" label="Loading test results" />
Guidelines
- Use a spinner for short waits of unknown length, such as saving, deploying, or fetching.
- Put it where the icon would be, in a button or a badge, so the layout doesn't shift when loading starts. It takes that icon's size and the text color.
- Disable the button while its action is running, and keep its label, or switch it to what's happening, such as Deploying.
-
It's announced as Loading. Pass
labelto say what's loading when the text around it doesn't. - It moves like a real object: it eases over the top and is pulled quickly through the bottom, stretching like elastic, and no two laps are alike. For people who prefer reduced motion, it turns slowly at a constant speed.
API reference
<.spinner>
| Attribute | Type | Default | Description |
|---|---|---|---|
|
label
|
string
|
"Loading"
|
What's loading, announced to screen readers
|
|
size
|
string
|
nil
|
12px, 16px, or 20px. Inside a button or a badge, it takes the icon's size instead.
nil"small""medium""large"
|
Also accepts global attributes.