Spinner

A compact, indeterminate loading indicator for short waits where the layout of the result is unknown. Prefer a skeleton for content areas, a progress bar when progress is measurable and a button's loading state for actions.

  • vig-spinner
Import
import { Spinner } from '@vigdx/ui/spinner';

Sizes

size is sm (1em), md (1.5em, default) or lg (2em), all relative to the font size, so a spinner also grows with its surrounding text.

Variants

variant sets the ring color: primary (default), secondary for quiet placements, or one of the status hues.

In context

Next to a visible status, give the spinner the same text as ariaLabel and hide the duplicate; as a panel placeholder, center it in the loading region. ariaLabel also translates the spinner's name.

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="spinner"][data-part="ring"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="spinner"]

Spinner styling hooks
Part Element data-state
ring The spinning ring. —

Accessibility

  • The spinner is an indeterminate role="progressbar" named by its ariaLabel (default: the spinnerAriaLabel label, “Loading”). It is not a live region, so it is read when users reach it rather than announced each time it appears.
  • Name what is loading, e.g. “Loading orders”. If the start of a long load matters, announce it yourself through a polite status message.
  • Render the spinner only while loading. Removing it does not announce completion; show the result or a message instead.
  • With prefers-reduced-motion the ring keeps turning, much slower (6s per turn): a still ring would read as stalled.

API

Spinner

vig-spinner component

Indeterminate loading indicator, sized relative to the surrounding font. Exposed as an indeterminate progressbar named by its label — a loading indicator is not a live region, so it is not announced each time it appears; announce completion separately if it matters. With reduced motion the ring keeps turning, much slower, so it still reads as busy.

Spinner props
Name Type Default Description
ariaLabelstring | undefinedundefined

Accessible name; defaults to the spinnerAriaLabel label.

sizeSpinnerSize'md'
—
variantSpinnerVariant'primary'
—

Are you sure?