Spinner
An SVG loading spinner with size variants
Installation
pnpm dlx shadcn@latest add https://prototyper-ui.com/r/spinner.jsonnpx shadcn@latest add https://prototyper-ui.com/r/spinner.jsonyarn dlx shadcn@latest add https://prototyper-ui.com/r/spinner.jsonbunx --bun shadcn@latest add https://prototyper-ui.com/r/spinner.jsonThis will add the following files to your project:
components/ui/spinner.tsx
Usage
import { Spinner } from "@/components/ui/spinner";
<Spinner />;Examples
Sizes
Loading...
In Button
Loading...
Styling
Data Slots
Use data-slot attributes to target the spinner in CSS:
| Slot name | Element |
|---|---|
spinner | The <svg> root |
Customization Examples
/* Change spinner color */
[data-slot="spinner"] {
@apply text-primary;
}{
/* Custom color via className */
}
<Spinner className="text-primary" size="lg" />;API Reference
Spinner
An SVG loading spinner with rotation animation.
Prop
Type
Extends React.ComponentProps<"svg">. All standard SVG props are forwarded via ...props.
spinnerVariants
A cva helper exported for use outside of the <Spinner> component.
Accessibility
Keyboard Interactions
Spinner is a non-interactive presentational element and does not have keyboard interactions.
ARIA Attributes
- Add
role="status"andaria-label="Loading"when the spinner indicates an ongoing operation. - Use
aria-busy="true"on the parent container while loading.