Components

Spinner

An accessible React loading spinner with role="status", a screen-reader label and four sizes — plus five animated loaders built with Motion: bouncing dots, equalizer bars, a gradient ring, an orbit and a radar pulse, all respecting reduced motion.

  • role="status"
  • Server Component friendly
  • currentColor
  • prefers-reduced-motion
  • Dots loaderDots
  • Bars loaderBars
  • Ring loaderRing
  • Orbit loaderOrbit
  • Pulse loaderPulse

Installation

$ npx shadcn@latest add https://duskui.com/r/spinner.json

Adds components/ui/spinner.tsx. CSS only, colored with currentColor, so it inherits the text color of buttons and badges.

Usage

loading.tsx
import { Spinner } from "@/components/ui/spinner"

export function Loading() {
  return <Spinner size="lg" className="text-primary" label="Loading projects" />
}

Examples

Sizes & colors

size is sm, default, lg or xl, and text-* classes recolor it.

LoadingLoadingLoadingLoading dashboardLoading

In buttons, badges & rows

When the surrounding text already says what's happening ("Saving…"), add aria-hidden to the spinner so it isn't announced twice. Keep busy buttons focusable with aria-disabled and aria-busy.

Deploying
Fetching messagesFetching new messages…

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Animated Loaders

Five loaders from one file: DotsLoader, BarsLoader, RingLoader, OrbitLoader and PulseLoader. Each is a role="status" box with a hidden label, drawn in currentColor and sized in pixels. Under reduced motion they stop moving and fade in turn instead.

  • Dots loaderDots
  • Bars loaderBars
  • Ring loaderRing
  • Orbit loaderOrbit
  • Pulse loaderPulse
$ npx shadcn@latest add https://duskui.com/r/loaders.json
PropTypeDefaultDescription
sizenumber32Width and height in pixels.
labelstring"Loading"Text announced to screen readers.
speednumber—Seconds per loop; lower is faster. Each loader has its own default.
barsnumber5BarsLoader only. Number of bars.
thicknessnumber3RingLoader only. Ring thickness in pixels.
ringsnumber2PulseLoader only. Number of ripples.

Loaders in context

Dots for a typing indicator, a pulse for a live connection, a thin ring inside a button. Recolor any loader with text-*.

AIAssistant is typing
LiveListening for eventslive
$ npx shadcn@latest add https://duskui.com/r/loaders.json

API Reference

Spinner renders a <span role="status"> and forwards span props.

PropTypeDefaultDescription
size"sm" | "default" | "lg" | "xl""default"Spinner size.
labelstring"Loading"Screen-reader text inside the status region.

Accessibility

  • Every spinner and loader is a role="status" live region with visually hidden text, so the loading state is announced instead of being a silent icon.
  • Pass a specific label ("Loading invoices") when several things can load at once.
  • Mark the busy container with aria-busy="true" while content loads, and remove the spinner when it's done.
  • Under prefers-reduced-motion the Spinner turns slowly and the loaders fade instead of moving, so progress is still visible without motion.