Spinner
spinneruiLightweight loading indicator — circular spinner with three sizes and tone variants. Use inside buttons (replacing the icon when an action is in flight) or as a centered page loader.
Installation
$pnpm dlx shadcn@latest add https://uipkge.dev/r/lit/spinner.json$npx shadcn@latest add https://uipkge.dev/r/lit/spinner.json$yarn dlx shadcn@latest add https://uipkge.dev/r/lit/spinner.json$bunx shadcn@latest add https://uipkge.dev/r/lit/spinner.jsonManifest:
https://uipkge.dev/r/lit/spinner.jsonInstalls to:src/uip/components/spinner/Examples
Live demo coming soon — source below is exact.
Props
| Name | Type / Values | Default | Required |
|---|---|---|---|
size | 'default''sm''lg''icon' | default | optional |
Schema
Type aliases from this item's source — use them to shape the data you pass in.
HTMLElementTagNameMapinterface HTMLElementTagNameMap {
'uip-spinner': UipSpinner
}
}npm dependencies
Includes
Files installed (2)
src/uip/components/spinner/spinner.ts2 kB
import { LitElement, css } from 'lit' import { Loader2 } from 'lucide' import { tailwind } from '../../lib/styles' import { ThemeController } from '../../lib/theme' import { icon } from '../../lib/icon' import { spinnerVariants, type SpinnerVariants } from './spinner.variants' type Size = NonNullable<SpinnerVariants['size']> /** * <uip-spinner> — the registry Spinner (a spinning Loader2) as a web component. * * Class string is React's `spinnerVariants` verbatim. The icon is the same * Loader2 node lucide-react renders, so the `lucide lucide-loader-circle` * classes match. `role="status"` + `aria-label="Loading"` like React. * * React's `className` (size/color overrides) → style `part="base"` from the * host, e.g. `class="[&::part(base)]:size-8 [&::part(base)]:text-primary"`. */ export class UipSpinner extends LitElement { // :host display can't be a utility class (the host has no template of its own). static styles = [tailwind, css`:host { display: inline-flex; }`] static properties = { size: { reflect: true }, } size: Size = 'default' constructor() { super() new ThemeController(this) } connectedCallback() { super.connectedCallback() this.setAttribute('data-uipkge', '') this.setAttribute('data-slot', 'spinner') } protected updated() { // icon() takes no extra attributes; stamp React's data/ARIA attributes and // the styling part onto the rendered svg. const svg = this.renderRoot.querySelector('svg') if (svg) { svg.setAttribute('part', 'base') svg.setAttribute('data-uipkge', '') svg.setAttribute('data-slot', 'spinner') svg.setAttribute('role', 'status') svg.setAttribute('aria-label', 'Loading') } } render() { return icon(Loader2, 'loader-circle', spinnerVariants({ size: this.size })) } } customElements.get('uip-spinner') || customElements.define('uip-spinner', UipSpinner) declare global { interface HTMLElementTagNameMap { 'uip-spinner': UipSpinner } }src/uip/components/spinner/spinner.variants.ts0.8 kB
import type { VariantProps } from 'class-variance-authority' import { cva } from 'class-variance-authority' /** * Variant definitions live in their own file (rather than the package * `index.ts`) so consuming Vue SFCs can import without creating a circular * dependency through the index. See card.variants.ts for the canonical * example + the SSR symptom that motivated the split. */ // motion-safe: honor prefers-reduced-motion (static glyph when reduced). export const spinnerVariants = cva('motion-safe:animate-spin text-muted-foreground', { variants: { size: { default: 'size-6', sm: 'size-4', lg: 'size-8', icon: 'size-4', }, }, defaultVariants: { size: 'default', }, }) export type SpinnerVariants = VariantProps<typeof spinnerVariants>
Raw manifest:https://uipkge.dev/r/lit/spinner.json