Spinner
FreeNewA ring with a moving arc in the current text color, in three sizes.
Installation
pnpm dlx shadcn@latest add @viewport/spinner
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above.
import { Spinner } from "@/components/viewport/spinner";
export default function SpinnerDemo() {
return (
<div className="flex flex-col items-center gap-6">
<div className="flex items-center gap-6 text-muted-foreground">
<Spinner size="sm" label="Loading, small" />
<Spinner label="Loading, medium" />
<Spinner size="lg" label="Loading, large" />
</div>
{/* The text already says what is happening, so the spinner itself stays silent. */}
<p role="status" className="inline-flex items-center gap-2 rounded-full border border-border bg-card px-3.5 py-2 text-sm">
<Spinner size="sm" label="" />
Syncing 1,284 contacts
</p>
</div>
);
}Props
| Prop | Type | Default |
|---|---|---|
| size | keyof typeof sizes | "md" |
| label | stringWhat is loading, for screen readers. Pass an empty string when nearby text already says it. | "Loading" |
Accessibility
- A status with a label, or silent when nearby text already says what is loading.
- Turns more slowly under reduced motion instead of freezing, which would read as a hang.
- Server component with no client JavaScript.