Spinner
A lightweight, accessible loading indicator. Use it for in-place activity that has no measurable progress (a form submitting, a panel fetching) — when you can show a layout preview instead, reach for Skeleton; when you have a measurable percentage, reach for Progress.
The spinner carries role="status" and a visually hidden label, so its state is
text a screen reader can read, whatever the animation does. A live region
announces a change of its content, not the content it holds when it appears, so
a spinner that comes and goes is announced inside a status region that stays on
the page, as in Livewire.
Basic Usage
Sizes
Four sizes cover everything from inline-with-text to a page-center loader.
Color
By default the spinner inherits the surrounding text color (currentColor), so
it matches whatever context you drop it into. Set intent for a standalone
semantic color — every value maps to a theme token, so it restyles with the
active theme.
In Context
Because the spinner inherits currentColor, it sits naturally inside a button,
a badge, or any text run.
Livewire
Pair with wire:loading to show the spinner only while a request is in flight.
The status region is on the page before the request starts, so the words that
appear in it are announced; the spinner beside them is decoration:
{{-- 1. The region is on the page before saveProfile() starts --}}
<div role="status" aria-live="polite">
{{-- 2. Shown during the round-trip only, and announced when it appears --}}
<span wire:loading wire:target="saveProfile">
<x-wirekit::spinner intent="accent" aria-hidden="true" /> Saving your profile…
</span>
</div>
{{-- 3. The real content hides while loading --}}
<div wire:loading.remove wire:target="saveProfile">
{{-- saved state --}}
</div>
A spinner shown with wire:loading on its own appears already holding its
label, and assistive technology generally announces only a change of a live
region's content (MDN: ARIA live regions),
so it is read when someone looks for it but not announced when it appears.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size |
string | 'md' |
sm, md, lg, xl |
intent |
string|null | null |
null inherits currentColor; or accent, success, warning, danger, neutral. primary is accepted as an alias of accent, and info draws in --color-wk-info-text, which follows the accent until you give info a color of its own, and every intent in its text tone, which holds 3:1 on the page |
label |
string | 'Loading' |
Screen-reader accessible name, the text of the live region |
scope |
string|null | null |
Scoped personalization name |
Accessibility
- The wrapper carries
role="status"+aria-live="polite", a polite live region: a change of its label is announced without interrupting, and a screen reader's command for the current status reads it. A spinner that appears already holding its label is generally not announced; see Livewire for a region that stays on the page. - The visually-hidden
label(default"Loading") is the accessible name — set it to something specific likelabel="Loading results"when helpful. - The SVG glyph is
aria-hidden="true"; the meaning is carried entirely by the live-region text, so the loading state is conveyed even when motion is reduced. - Pair with
aria-busy="true"on the region being loaded for the fullest assistive-technology signal. - Under
prefers-reduced-motion: reducethe rotation stops — the glyph stays on screen as a static ring and the status text is unchanged, so nothing about the loading state depends on the movement. This matches what the other indeterminate indicators (progressin its indeterminate mode, the skeleton shimmer) already do; it is not something you opt into.
Keyboard Interaction
This component is purely presentational and does not respond to keyboard input.
Pitfalls
- Don't use a spinner when you have a layout to preview. A Skeleton that mirrors the eventual content reduces perceived load time better than a bare spinner.
- Don't use a spinner when you know the percentage. A Progress bar communicates "how much longer" — a spinner cannot.
- Give long loads a specific label.
label="Loading invoices"is more useful to a screen-reader user than the generic default.
Design Tokens
| Element | Token |
|---|---|
| Default color | currentColor (inherited) |
intent="accent", intent="primary" |
--color-wk-accent-text |
intent="info" |
--color-wk-info-text |
intent="success" |
--color-wk-success-text |
intent="warning" |
--color-wk-warning-text |
intent="danger" |
--color-wk-danger-text |
intent="neutral" |
--color-wk-text-muted |
Glyph dimensions (h-4/h-5/h-6/h-8) are structural SVG sizes, matching the
icon-sizing convention used across WireKit.