|Kit

Spinner

Inline activity indicator. Inherits color and size by default so Button / ActionIcon embed it cleanly; opt-in props for standalone use.

Spinner is a self-contained SVG indicator. The strokes use currentColor, so when color is omitted it inherits the surrounding text color — that's how Button and ActionIcon embed it without extra plumbing. Pass a palette color for standalone use to route through the kit's slot vars.

Two non-palette values round out the prop: "currentColor" is the explicit, named form of the inherit behavior, and "default" paints the neutral high-contrast stroke that matches Button's default variant.

import { Spinner } from '@42-central/ui-react/spinner';

<Spinner color="brand" size="lg" />
<Spinner label="Syncing" color="green" size="md" />
<Spinner color="default" size="lg" />        {/* matches Button's default variant */}
<Spinner color="currentColor" size="lg" />   {/* explicit inherit */}

Playground

Component

Loading preview

Props

Code

<Component size="xl" label="Loading" />

Inheritance vs explicit

When used inside a container that already drives text color and SVG size (Button / ActionIcon), omit both color and size — Spinner picks them up via CSS inheritance.

Code

<Button color="brand" loading>Saving</Button>
<Button color="green" variant="light" loading>Syncing</Button>
<Button color="red" variant="outline" loading>Deleting</Button>

Sizes

LoadingLoadingLoadingLoadingLoading

Code

<Spinner size="xs" color="brand" />
<Spinner size="sm" color="brand" />
<Spinner size="md" color="brand" />
<Spinner size="lg" color="brand" />
<Spinner size="xl" color="brand" />

Accessibility

label controls the screen-reader announcement:

  • Default (label="Loading"): the root is a role="status" live region named by the label, with the label as visually hidden text inside it, so screen readers announce "Loading" as a status rather than reading a picture. The ring itself is aria-hidden.
  • Custom: pass any string for a more specific phrase ("Syncing", "Submitting form"), or a translated one: label is the spinner's only microcopy.
  • Decorative (label={null}): the whole spinner is aria-hidden, with no role and no text. Use when a parent already broadcasts the busy state (e.g. Button's aria-busy="true" covers any embedded spinner).

Under prefers-reduced-motion: reduce the spinner stops and the arc rests in place, the same rule the kit applies to the indeterminate Progress and CircularProgress. The status text is unaffected.

<Spinner label="Syncing your library" color="green" />

{/* When the parent has aria-busy, mark the spinner decorative. */}
<Button loading>Saving</Button>
{/* Button internally renders <Spinner label={null} /> */}

API

Prop

Type

All other props, className included, are forwarded to the root <span>, which is the element that spins (so an [animation-play-state:paused] class pauses it).

Changelog

v0.20.0
  • Spinner renders a <span role="status"> instead of an <svg role="img">, so its props are span props and className/testId/rest land on the root; it stops spinning under reduced motion

    #388
v0.19.0
  • Spinner's accessible name comes from label, and label={null} takes it out of the accessibility tree, so loading Buttons and ActionIcons no longer expose an extra "Spinner" image

    #319
v0.0.1
  • Spinner

On this page