Spinner¶
An inline spinner with a hidden status label. Its size is small, medium, or large.
Decision¶
| When | Use |
|---|---|
| One request in flight, beside a button or inside a region | Spinner |
| Content that has a known shape | Skeleton |
| A known percent | Progress Ring |
Usage¶
import { createSpinner } from './configurationpage?name=myplugin_stolon.js';
status.appendChild(createSpinner({ size: 'small', label: 'Saving' }).element);
Classes: stolon-loading, stolon-loading-small, stolon-loading-medium, stolon-loading-large, stolon-loading-ring. The handle is { element, getValue, setValue, destroy }, where getValue() returns the label and setValue(label) replaces it.
The one animation in the kit is the stolon-spin keyframes, a turn from 0 to 360 degrees. A plugin may use it for its own element.
.my-spinner { animation: stolon-spin 0.8s linear infinite; }
States and Modifiers¶
stolon-loadingis an inline wrapper withrole="status", andlabel("Loading") is the text a screen reader reads.- With reduced motion asked for, the ring turns slower and still turns.
stolon-table-reload-btn.spinning .material-iconsusesstolon-spinfor the Paginated Table reload button.
Gotchas¶
- The
stolon-spinnerclass belongs to the status page template. See Status Page. - The ring is
stolon-loading-ring. There is no spinner class in the bundled CSS other than these.
Reference¶
Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.
createSpinner¶
function createSpinner(options?: SpinnerOptions): SpinnerHandle
An inline spinner with a hidden status label. Its size is small, medium, or large.
| Option | Type | What it does |
|---|---|---|
size |
'small' | 'medium' | 'large' | string |
'small', 'medium', or 'large' (default 'medium') |
label |
string |
text a screen reader reads (default 'Loading') |
| Handle member | Type |
|---|---|
getValue |
(): string |
setValue |
(label: string): void |
destroy |
(): void |
| Class | What it looks like |
|---|---|
stolon-loading |
Inline spinner, a ring with one accent edge that turns, in three sizes |
Example¶
Example Code¶
<!-- title: Spinner -->
<div id="mount"></div>
<script type="module">
const base = await window.__baseReady;
const view = document.getElementById('view');
const mount = document.getElementById('mount');
mount.style.cssText = 'display:flex;align-items:center;gap:16px';
['small', 'medium', 'large'].forEach((size) => mount.appendChild(base.createSpinner({ size }).element));
</script>