Feedback
Spinner
Free10.3 KB gzippedAn indeterminate loading indicator.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report
Import
import { Spinner } from "@vjdesigns/vjdesigns-ui";
Importing only Spinner adds about 10.3 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Variants and sizes
Spinners have role="status" and a label ("Loading" by default) for screen readers.
import { Flex, Spinner, Stack } from "@vjdesigns/vjdesigns-ui";
export function VariantsAndSizes() {
return (
<Stack gap={5} align="center">
<Flex gap={6} align="center">
<Spinner variant="ring" tone="primary" />
<Spinner variant="dots" tone="primary" />
<Spinner variant="bars" tone="primary" />
</Flex>
<Flex gap={6} align="center">
<Spinner size="sm" />
<Spinner size="md" />
<Spinner size="lg" />
<Spinner size="xl" tone="accent" />
</Flex>
</Stack>
);
}
In context
delay waits before appearing, so quick loads don't flash a spinner. Use decorative when nearby text already says it's loading.
import { Button, Flex, Spinner } from "@vjdesigns/vjdesigns-ui";
export function InContext() {
return (
<Flex gap={3} align="center">
<Spinner size="sm" decorative />
<span>Loading messages…</span>
<Button variant="ghost" tone="neutral" size="sm">
Cancel
</Button>
</Flex>
);
}
Accessibility
A spinner on its own is announced through a role="status" region with its label. Inside a button that already says what's happening, make it decorative; and delay avoids a flash when the work finishes quickly.
import { Button, Flex, Spinner } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<Flex gap={6} align="center" wrap="wrap">
<Spinner label="Loading your orders" delay={300} />
<Button loading loadingText="Saving…">
Save
</Button>
</Flex>
);
}
Translated
Without a label, the spinner's announcement ("Chargement") comes from the locale (French here).
import { Spinner, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import fr from "@vjdesigns/vjdesigns-ui/locales/fr";
export function Translated() {
return (
<LocaleProvider locale="fr" messages={fr}>
<Spinner />
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Variants and sizes
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// VariantsAndSizes is the "Variants and sizes" example above.
<LocaleProvider locale="ar" messages={ar}>
<VariantsAndSizes />
</LocaleProvider>
Usage notes
By default it is a role="status" region with a visually hidden label ("Loading"), so screen readers hear that something is in progress. Pass decorative when a parent already communicates the busy state.
Under prefers-reduced-motion: reduce the spinning and bouncing stop: the ring holds a static partial arc (its faint track gently pulses), and dots and bars fade in sequence instead of moving.
<Spinner />
<Spinner variant="dots" tone="primary" size="lg" label="Loading roster" />
<Button startIcon={<Spinner decorative size="sm" />}>Syncing</Button>
API reference
Spinner
| Prop | Type | Default |
|---|---|---|
sizeSize of the spinner: a named step from the | SpinnerSize | number | "md" |
toneColor. | "neutral""primary""accent""success""warning""danger""info""inherit" | "inherit" |
variantVisual style. | "ring""dots""bars" | "ring" |
thicknessStroke width of the | number | — |
labelText announced to screen readers through a | string | "Loading" |
decorativeHides the spinner from assistive technology ( | boolean | false |
delayMilliseconds to wait before rendering anything. Avoids a flash of spinner when the work finishes quickly. | number | 0 |
Also accepts native <span> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Spinner targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
Not focusable, so there's no keyboard interaction of its own.
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Spinner | status | Named by label ("Loading") |
decorative | none | aria-hidden="true", for spinners inside a busy control |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |