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.
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
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.
Sizes
<Spinner size="sm" />
<Spinner size="md" />
<Spinner size="lg" /> Variants
<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…").
<Spinner label="Loading results…" /> Features
- Accessible -
role="status"andaria-labelso 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