Skip to content
TopClass UI

Spinner

For a wait of unknown length. A spinner is an icon, so it takes the icon sizes, 16 to 40 px, and can follow the text it sits in.

server - 0 KB

Spinner

server - 0 KB

For a wait of unknown length. A spinner is an icon, so it takes the icon sizes, 16 to 40 px, and can follow the text it sits in.

Install

Try it

size
tone

The code

spinner.tsx
import { Spinner } from 'topclassui/spinner'

<Spinner />

Prefer Skeleton when the shape of what is coming is known; Spinner is for unknown waits.

Every state

3 states

Decorative, in the text colour

Import from the package

topclassui/spinner
import { Spinner } from 'topclassui/spinner'

Install once:npm i topclassui@beta zod

Examples

  • For a route still loading or a preview still building. When the shape of what is coming is known, a list or a table among them, a Skeleton holds its place instead.
  • size="custom" sets no size, so the spinner is 1em and grows with the text around it.
  • To take the colour of the surrounding text instead of a tone, pass className="text-current".
with-text

Building your preview

sizes
tones
inherit-color

Retrying the payment

Saving the draft

custom-size

Syncing at text-sm

Syncing at text-lg

Syncing at text-3xl

In Arabic, right to left

جارٍ تحميل المعاينة

Props

The props of Spinner
PropTypeDefaultLimitsDescription
labelsLabels--The built-in strings; the accessible name is labels.common.loading. Defaults to English.
localestring--Accepted so {...getLabels(locale)} spreads cleanly. Nothing here formats a number, so it is not used and never reaches the element.
sizexs | sm | md | lg | xl | custom"md"-The icon scale, 16 to 40 px; custom sets no size, so it follows the text at 1em.
toneprimary | neutral | success | warning | danger | info"primary"-The colour ramp it draws in; className="text-current" takes the text colour instead.

Keyboard and accessibility

Nothing to operate: it is not interactive on its own.

  • Named but silent: an image named by labels.common.loading, or your own aria-label, with no live region.
  • Beside text that already names the wait, pass aria-hidden so the wait is not read twice.
  • In forced colours it takes the system text colour of its parent, so it stays visible in Windows high contrast, and reduced motion stops the turn.

Right to left

The circle turns the same way in both directions: it is never flipped. With the Arabic labels its default name is Arabic too.

Server and client

Renders on the server and ships no JavaScript.

Files: index.tsx.

On the chip: server - 0 KB.