For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
FrakmentFrakment

Spinner

An indicator that can be used to show a loading state.

Web
Frakment
Processing payment...
$100.00
spinner.tsx
import { LoaderIcon } from "lucide-react";

import { cn } from "@/lib/utils";

function Spinner({
  className,
  variant = "default",
  borderWidth,
  ...props
}: React.ComponentProps<"span"> & {
  variant?: "default" | "spoke";
  borderWidth?: number;
}) {
  if (variant === "spoke") {
    return (
      <span
        aria-label="Loading"
        className={cn(
          "inline-flex size-4 shrink-0 items-center justify-center",
          className
        )}
        data-slot="spinner"
        data-variant="spoke"
        role="status"
        {...props}
      >
        <span className="block size-full [transform-origin:center] animate-spin [transform-box:view-box] motion-reduce:animate-none">
          <LoaderIcon className="block size-full [shape-rendering:geometricPrecision]" />
        </span>
      </span>
    );
  }

  return (
    <span
      aria-label="Loading"
      className={cn(
        "inline-block size-4 shrink-0 animate-spin rounded-full border-current border-t-transparent motion-reduce:animate-none",
        borderWidth === undefined ? "border-2" : "",
        className
      )}
      data-slot="spinner"
      data-variant="default"
      role="status"
      style={
        borderWidth === undefined
          ? undefined
          : { borderWidth: `${borderWidth}px` }
      }
      {...props}
    />
  );
}

export { Spinner };

Spinner renders a loading indicator. It carries role="status" and aria-label="Loading" so screen readers announce a live state. Two shapes are available: default (a circular arc, rendered as CSS border for zero rotation jitter) and spoke (a sunburst, from LoaderIcon).

Installation

Usage

spinner.tsx
import { Spinner } from "@/components/ui/spinner";
tsx
<Spinner />

Examples

Shapes

default renders a circular arc. spoke renders a sunburst from LoaderIcon.

default
spoke
spinner-shapes.tsx
import { Spinner } from "@/components/ui/spinner";

export function SpinnerShapes() {
  return (
    <div className="flex flex-wrap items-center gap-8">
      <div className="flex flex-col items-center gap-2">
        <Spinner className="size-6" />
        <span className="text-muted-foreground text-xs">default</span>
      </div>
      <div className="flex flex-col items-center gap-2">
        <Spinner className="size-6" variant="spoke" />
        <span className="text-muted-foreground text-xs">spoke</span>
      </div>
    </div>
  );
}

Size

Use a size-* utility class to change the diameter. Default is 16px (size-4).

spinner-size.tsx
import { Spinner } from "@/components/ui/spinner";

export function SpinnerSize() {
  return (
    <div className="flex items-center gap-6">
      <Spinner className="size-3" />
      <Spinner className="size-4" />
      <Spinner className="size-6" />
      <Spinner className="size-8" />
    </div>
  );
}

Button

Place the spinner before the label with data-icon="inline-start", or after with data-icon="inline-end". The button uses the attribute for gap spacing.

spinner-button.tsx
import { Button } from "@/components/ui/button";
import { Spinner } from "@/components/ui/spinner";

export function SpinnerButton() {
  return (
    <div className="flex flex-wrap items-center gap-3">
      <Button disabled>
        <Spinner data-icon="inline-start" />
        Processing
      </Button>
      <Button disabled variant="outline">
        <Spinner data-icon="inline-start" />
        Saving
      </Button>
      <Button disabled variant="secondary">
        Loading
        <Spinner data-icon="inline-end" />
      </Button>
    </div>
  );
}

Badge

Same idea inside a badge — data-icon keeps the gap aligned with the badge icon size.

SyncingUpdatingProcessing
spinner-badge.tsx
import { Badge } from "@/components/ui/badge";
import { Spinner } from "@/components/ui/spinner";

export function SpinnerBadge() {
  return (
    <div className="flex flex-wrap items-center gap-2">
      <Badge>
        <Spinner data-icon="inline-start" />
        Syncing
      </Badge>
      <Badge variant="secondary">
        <Spinner data-icon="inline-start" />
        Updating
      </Badge>
      <Badge variant="outline">
        Processing
        <Spinner data-icon="inline-end" />
      </Badge>
    </div>
  );
}

In context

Combine with a shimmer text for a live streaming line.

Thinking…
spinner-in-context.tsx
import { Spinner } from "@/components/ui/spinner";

export function SpinnerInContext() {
  return (
    <div className="w-full max-w-sm py-4">
      <div className="text-muted-foreground mx-auto flex w-fit items-center gap-2 text-sm">
        <Spinner />
        <span className="shimmer">Thinking…</span>
      </div>
    </div>
  );
}

API Reference

Spinner

PropTypeDefaultDescription
variant
defaultspoke
—Icon shape — circular arc (default) or sunburst (spoke).
borderWidthnumber—Custom border thickness for the default variant. Defaults to Tailwind border-2.

Extends React.ComponentProps<"span">. Defaults: size-4, animate-spin, role="status", aria-label="Loading".

Accessibility

  • Renders role="status" and aria-label="Loading" by default — screen readers treat it as a live region.
  • Pair with visible text for clarity when the loading state has semantic meaning.
  • animate-spin respects prefers-reduced-motion via motion-reduce:animate-none.
  • When placed inside Button or Badge, keep data-icon="inline-start" or "inline-end" so the gap matches the surrounding component.

Best Practices

  • Pair with text. A spinner alone is ambiguous.
  • Do not block the whole page. Use a skeleton for content areas.
  • Respect reduced motion. When prefers-reduced-motion is set, the icon renders static.
  • Hide after success. A lingering spinner reads as "still loading".
  • Button — disabled loading button
  • Badge — inline status badge