Spinner
A rotating Keyline loader glyph.
Size it with a size-* class; it takes the text colour. It keeps turning when the person prefers reduced motion, because it reports progress.
Default
import { Spinner } from "@/components/ui/spinner"
export default function SpinnerDefault() {
return <Spinner />
}
Sizes
import { Spinner } from "@/components/ui/spinner"
export default function SpinnerSizes() {
return (
<div className="flex items-center gap-6">
<Spinner className="size-3" />
<Spinner />
<Spinner className="size-6" />
<Spinner className="size-8 text-muted-foreground" />
</div>
)
}
Beside a label
Importing 214 rows
import { Button } from "@/components/ui/button"
import { Spinner } from "@/components/ui/spinner"
export default function SpinnerBesideALabel() {
return (
<div className="flex flex-col items-center gap-4">
<p role="status" className="flex items-center gap-2 text-muted-foreground">
<Spinner aria-hidden />
Importing 214 rows
</p>
<Button disabled>
<Spinner data-icon="inline-start" aria-hidden />
Saving
</Button>
</div>
)
}
With its own name
import { Spinner } from "@/components/ui/spinner"
export default function SpinnerWithItsOwnName() {
return <Spinner aria-label="Loading the invoice" className="size-6" />
}
Installation
npx shadcn@latest add @khaeli/spinnerbunx --bun shadcn@latest add @khaeli/spinnerInstall @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.
Installs with
- Registry items
- npm packages
- @keyline-icons/react ^2.2.0
Accessible name
- By itself the spinner is a status named Loading (
role="status",aria-label="Loading"). Pass your ownaria-labelto say what is loading. - Beside text that already says what is happening, hide the spinner with
aria-hiddenand let the text speak. Put the text in arole="status"element when it appears while the page is in use. - In a pending button, hide the spinner with
aria-hiddenand keep a button text that names the state, such as Saving.
Registry JSON
The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/spinner.json