implement
Spinner

Spinner

A turning ring for work in flight.

import { Div } from "@implementjs/core";
import { Button } from "@/lib/components/ui/button";
import { Spinner } from "@/lib/components/ui/spinner";

export default function SpinnerDemo() {
	return Div(
		{ class: "flex flex-wrap items-center justify-center gap-6" },
		Spinner({ "aria-label": "Loading projects" }),
		Spinner({ class: "size-6 text-muted-foreground", "aria-label": "Loading" }),
		Button({ disabled: true }, Spinner(), "Saving"),
	);
}

Installation

npx jsrepo add @implementjs/ui/spinner

It installs @implementjs/lucide at the same time.

Usage

import { Spinner } from "@/lib/components/ui/spinner";

Spinner({ "aria-label": "Loading projects" });

It carries role="status" and a default label, so a screen reader announces the wait. Pass aria-label to say what is being waited on.

In a button

A button that is working should say so and stop accepting clicks:

Button({ disabled: true }, Spinner(), "Saving");

The button's base styles already size and space an icon inside it, so the spinner needs no classes of its own here.

Determinate work

A spinner says something is happening. When you know how far along it is, say that instead — use progress.

Reduced motion

The spin stops under prefers-reduced-motion, leaving a static ring.

API Reference

Spinner

A turning ring for work in flight. Carries role="status" and a default label; pass aria-label to say what is loading. Size and color it with classes, like any icon. Renders a LoaderCircleIcon; extra props are forwarded onto it.