Spinner
An indeterminate progress indicator that is a Server Component and keeps spinning under reduced motion.
View as Markdown for coding assistants, or see llms.txt.
- Stable
- Group: Feedback
- Added in @azmr/ui 0.2.0
Usage
import { Spinner } from "@azmr/ui/spinner";import { Spinner } from "@azmr/ui/spinner";
export default function SpinnerBasic() {
return (
<div className="flex items-center gap-6">
{/* Decorative: the surrounding control already says it is busy. */}
<Spinner />
<Spinner className="size-6" />
{/* Announced as a status. */}
<Spinner className="size-8 text-primary" label="Loading customers" />
</div>
);
}Spinner is a Server Component (no hooks, no "use client"), so it works in loading.tsx and Suspense fallbacks without a client boundary. size runs from xs to xl (default sm, 1rem), or inherit for 1em; a size-* class still overrides it. Colour follows currentColor, or set tone. delay keeps it invisible for that many milliseconds, then fades it in (pure CSS).
For a visible message, your logo inside the spinner, a page or section loader, an overlay or a top-of-page bar, see Loading.
Decorative or announced
A spinner inside a control that already says it is busy (such as Button loading) should be decorative: it is aria-hidden by default. A spinner on its own needs a label, which makes it a role="status" that screen readers announce.
Reduced motion
Most motion in @azmr/ui stops under prefers-reduced-motion. A spinner does not: a frozen spinner reads as a hung page, which is worse than motion the user asked to avoid. It is marked data-motion="essential" to opt out of the reduced-motion rule.
Props
Prop
Type
Any SVG attribute passes through, and ref is the <svg>. className is merged last: size-8 text-primary.
Accessibility
- Decorative by default, announced only when you give it a
label. - No keyboard interaction; it is not focusable.
Loading
Spinners, loading messages, logo loaders, overlays for refetching data and a top-of-page loading bar. The message and spinner are Server Components and fine in loading.tsx.
State view
One layout for a region's loading, empty and error states, and an error boundary that reports errors, recovers and never shows error details to users.