GooseUI

Components

Spinner

New

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

npx shadcn@latest add @gooseui/spinner
pnpm dlx shadcn@latest add @gooseui/spinner
yarn dlx shadcn@latest add @gooseui/spinner
bunx --bun shadcn@latest add @gooseui/spinner

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

PropTypeDefaultDescription
labelstring"Loading"Hidden text for screen readers
classNamestring"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.