Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Feedback

Spinner

Free10.3 KB gzipped

An 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

tsx
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.

LoadingLoadingLoading
LoadingLoadingLoadingLoading
tsx
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.

Loading messages…
tsx
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.

tsx
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).

Chargement
tsx
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

جارٍ التحميلجارٍ التحميلجارٍ التحميل
جارٍ التحميلجارٍ التحميلجارٍ التحميلجارٍ التحميل
tsx
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.

tsx
<Spinner />
<Spinner variant="dots" tone="primary" size="lg" label="Loading roster" />
<Button startIcon={<Spinner decorative size="sm" />}>Syncing</Button>

API reference

Spinner

Spinner props
PropTypeDefault
size

Size of the spinner: a named step from the --icon-size-* scale, or a number of pixels for one-off cases.

SpinnerSize | number"md"
tone

Color. "inherit" follows the text color (currentColor). Tones map to contrast-verified text tokens: primary uses --color-primary, neutral uses --color-text, the rest use --color-{tone}-subtle-text.

"neutral""primary""accent""success""warning""danger""info""inherit""inherit"
variant

Visual style.

"ring""dots""bars""ring"
thickness

Stroke width of the ring variant, in pixels. Ignored by dots and bars. Defaults to scaling with the size (never thinner than --border-width-thick).

number—
label

Text announced to screen readers through a role="status" region. Not shown visually. Ignored when decorative.

string"Loading"
decorative

Hides the spinner from assistive technology (aria-hidden, no role, no label). Use when a parent already announces the busy state, such as a Button with loading or a region with aria-busy.

booleanfalse
delay

Milliseconds to wait before rendering anything. Avoids a flash of spinner when the work finishes quickly.

number0

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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 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

Roles and states
ElementRoleStates and properties
SpinnerstatusNamed by label ("Loading")
decorativenonearia-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.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)