codefast/ui

Command Palette

Search for a command to run...

Display

Spinner

Indeterminate loading indicator. Wrap children — shown when loading is false.

Install

pnpm add @codefast/ui

Import path

@codefast/ui/spinner

Examples

Badge

Add a spinner to a badge to indicate a loading state. Place the <Spinner /> before the label with data-icon='inline-start' for a start position, or after the label with data-icon='inline-end' for an end position.

SyncingUpdatingProcessing

Button

Add a spinner to a button to indicate a loading state. Place the <Spinner /> before the label with data-icon='inline-start' for a start position, or after the label with data-icon='inline-end' for an end position.

Customization

Replace the default spinner icon with any other icon.

Empty

An indicator that can be used to show a loading state.

Processing your request

Please wait while we process your request. Do not refresh the page.

Input Group

An indicator that can be used to show a loading state.

Validating...

RTL

Right-to-left layout support for languages such as Arabic and Hebrew.

Translations are AI-generated for demonstration and may be imperfect.

جاري معالجة الدفع...
١٠٠.٠٠ دولار

Size

Use the size-* utility class to change the size of the spinner.

Anatomy

How the parts compose. Copy this skeleton and fill in the slots.

import { Spinner } from "@codefast/ui/spinner";

<Spinner className="size-5" />

// with an accessible label
<Spinner>Loading…</Spinner>

API reference

Props for each part of the component. All native element props are also forwarded.

Spinner

An indeterminate loading indicator.

PropTypeDefaultDescription
loadingbooleantrueWhen false, renders children instead of the spinner.
childrenReactNodeUsed as a visually-hidden label while spinning.
classNamestringSet the size (e.g. size-5) and colour.

Accessibility

Built to be keyboard-navigable and screen-reader friendly out of the box.

  • Give the spinner a label via children so its purpose is announced.
  • Prefer a Spinner over a fake progress bar when you don’t know the duration.
  • Respect reduced motion — the animation is paused under prefers-reduced-motion.

Guidelines

Conventions that keep usage consistent across an app.

Do

  • Use for short, indeterminate waits.
  • Pair with disabled controls while an action is in flight.

Don’t

  • Don’t use a spinner for long, measurable tasks — use Progress.
  • Don’t show a bare spinner with no context about what’s loading.