Spinner Component — Astro

Accessible loading spinner with variants and sizes

Spinner Component

An accessible loading spinner for indicating progress when content is loading. Uses role="status" and an aria-label (default: "Loading") so screen readers announce the state. Supports multiple sizes and color variants.

Add this component

The command below includes <strong>Spinner</strong>—run it in your project directory to install this component (and the CSS if needed). No prompts.

Choose your package manager — click a tab to select, then copy the command.

npm pnpm yarn bun

Props

  • size (string, optional) - sm, md, lg (default: md)
  • variant (string, optional) - primary, success, warning, error, info (default: primary)
  • label (string, optional) - Accessible label for screen readers (default: "Loading")
  • class (string, optional) - Additional CSS classes

Basic Usage

Live Example

Usage

Full example for each framework (Astro, Vanilla, Svelte, Vue, React). Switch framework via View as or by clicking a Usage tab—both stay in sync.

Astro Vanilla Svelte Vue React

Sizes

Live Example
astro astro
<Spinner size="sm" />
<Spinner size="md" />
<Spinner size="lg" />

Variants

Live Example
astro astro
<Spinner variant="primary" />
<Spinner variant="success" />
<Spinner variant="warning" />
<Spinner variant="error" />
<Spinner variant="info" />

Custom Label

Use the label prop to describe the loading context for screen readers (e.g. "Loading results", "Saving…").

Live Example
astro astro
<Spinner label="Loading results…" />

Features

  • Accessible - role="status" and aria-label so screen readers announce loading
  • Variants - Primary, success, warning, error, info using theme variables
  • Sizes - sm, md, lg
  • Reduced motion - Animation disabled when user prefers reduced motion; static segment shown instead

Other frameworks: Vanilla · Svelte · Vue · React