A spinning icon that shows something is loading. It has role="status" and visually hidden text, so screen readers hear "Loading" while the icon itself stays hidden from them. Size and color come from className. Server component, no JavaScript.
Preview
Loading
Installation
Usage
import { Spinner } from "@/components/ui/spinner"
export default function Example() {
return <Spinner />
}Examples
Size and color
size-* sets the size, text-* the color: the icon is drawn with currentColor.
LoadingLoadingLoadingLoading
<Spinner className="size-3" />
<Spinner className="size-4 text-muted-foreground" />
<Spinner className="size-6 text-primary" />
<Spinner className="size-8 text-destructive" />Inside a button
Put the spinner before the label and disable the button while the request runs.
<Button disabled>
<Spinner label="Saving" />
Saving…
</Button>Custom text
label replaces the hidden text. Describe what is loading when there are several spinners on the page.
Loading comments
<Spinner label="Loading comments" />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | "Loading" | Hidden text for screen readers |
| className | string | "size-4" | size-* for the size, text-* for the color |
Features
- role="status": screen readers announce the hidden text.
- With reduced motion the icon spins much slower instead of stopping, so it still shows that work is going on.