Feedback
Spinner
Indeterminate loading indicator in four sizes and three tones.
Preview
import { Spinner } from "@/components/ui/spinner";
export default function Example() {
return (
<div className="flex items-center gap-6">
<Spinner size="xs" />
<Spinner size="sm" />
<Spinner size="md" />
<Spinner size="lg" />
<Spinner size="md" tone="neutral" />
<span className="flex size-12 items-center justify-center rounded-md bg-accent">
<Spinner size="md" tone="white" />
</span>
</div>
);
}Installation
Components are copied into your project — no runtime package.
Create a
spinner.tsxfile and paste the following code into it.src/components/ui/spinner.tsximport { cx } from "@/utils/cx"; export interface SpinnerProps { size?: "xs" | "sm" | "md" | "lg"; tone?: "accent" | "neutral" | "white"; /** Accessible label announced to screen readers. */ label?: string; className?: string; } const sizes = { xs: "size-3", sm: "size-4", md: "size-6", lg: "size-9" }; const tones = { accent: "text-accent", neutral: "text-fg-secondary", white: "text-white" }; /** Indeterminate loading indicator: a quarter arc spinning over a faint track. */ export function Spinner({ size = "md", tone = "accent", label = "Loading", className }: SpinnerProps) { return ( <span role="status" aria-label={label} className={cx("inline-flex shrink-0", sizes[size], tones[tone], className)}> <svg viewBox="0 0 24 24" fill="none" className="size-full animate-spin" aria-hidden> <circle cx="12" cy="12" r="9.5" stroke="currentColor" strokeOpacity="0.18" strokeWidth="3" /> <path d="M21.5 12a9.5 9.5 0 0 0-9.5-9.5" stroke="currentColor" strokeWidth="3" strokeLinecap="round" /> </svg> </span> ); }Add the theme tokens and the
cxhelper from Installation if you haven’t yet, then update the import paths to match your project setup.