---
title: "Spinner"
description: "Spinner component - loading indicators with CSS animations."
slug: "spinner"
---

import { DocPage, PageHeader, SkillPanel, SourceFiles, SourceNote, StatesSection, CodeBlock, Demo, DemoCode, ChangelogEntries, ArchBody, StatsClaim, StatsCards, PageOverlay, DocText, DocLink, H2, SkillField, SkillText, SkillRow, SkillGrid, Variant, ApiPill, Dim, CodeCard, TableCard } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="spinner" title="Spinner" component="spinner">
  An animated loading indicator. Pure CSS animation on an SVG element - no JavaScript required.
</PageHeader>

<SkillPanel component="spinner">
  <SkillField label="Native basis">
<SkillText>CSS <code>@keyframes</code> animation on an SVG element. No JavaScript required.</SkillText>
  </SkillField>

  <SkillField label="Web Platform APIs">
<SkillRow>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes" title="CSS animation for continuous rotation"><code>@keyframes</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/status_role" title="ARIA live region for loading state"><code>role="status"</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/SVG" title="scalable vector graphic for the spinner icon"><code>&lt;svg&gt;</code></ApiPill>
  </SkillRow>
  </SkillField>

  <SkillField label="Classes">
<SkillRow>
    <code>.spinner</code>
  </SkillRow>
  </SkillField>

  <SkillField label="Sizes (data-size)">
<SkillGrid>
    <Variant name="xs" description="Height: 0.625rem" />
    <Variant name="sm" description="Height: 0.875rem" />
    <Variant name="md" description="Height: 1.25rem" />
    <Variant name="lg" description="Height: 1.5rem" />
    <Variant name="xl" description="Height: 2rem" />
  </SkillGrid>
  </SkillField>

  <SkillField label="Accessibility">
<SkillText dense>• Must have <code>role="status"</code> and <code>aria-label="Loading"</code> (or contextual label)</SkillText>
  <p class="text-muted-foreground m-0">• Screen readers announce the loading state via the ARIA live region</p>
  </SkillField>
</SkillPanel>

```html example label="Default" hint="Standard spinner at default size."
<svg
  class="spinner"
  role="status"
  aria-label="Loading"
  viewBox="0 0 24 24"
  fill="none"
  stroke="currentColor"
  stroke-width="2"
  stroke-linecap="round"
  stroke-linejoin="round"
>
  <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
</svg>
```

```html example label="Sizes" hint="The full five-step scale via data-size - the default is 1rem, between sm and md."
<svg
  class="spinner"
  data-size="xs"
  role="status"
  aria-label="Loading (xs)"
  viewBox="0 0 24 24"
  fill="none"
  stroke="currentColor"
  stroke-width="2"
  stroke-linecap="round"
  stroke-linejoin="round"
>
  <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
</svg>
<svg
  class="spinner"
  data-size="sm"
  role="status"
  aria-label="Loading (sm)"
  viewBox="0 0 24 24"
  fill="none"
  stroke="currentColor"
  stroke-width="2"
  stroke-linecap="round"
  stroke-linejoin="round"
>
  <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
</svg>
<svg
  class="spinner"
  data-size="md"
  role="status"
  aria-label="Loading (md)"
  viewBox="0 0 24 24"
  fill="none"
  stroke="currentColor"
  stroke-width="2"
  stroke-linecap="round"
  stroke-linejoin="round"
>
  <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
</svg>
<svg
  class="spinner"
  data-size="lg"
  role="status"
  aria-label="Loading (lg)"
  viewBox="0 0 24 24"
  fill="none"
  stroke="currentColor"
  stroke-width="2"
  stroke-linecap="round"
  stroke-linejoin="round"
>
  <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
</svg>
<svg
  class="spinner"
  data-size="xl"
  role="status"
  aria-label="Loading (xl)"
  viewBox="0 0 24 24"
  fill="none"
  stroke="currentColor"
  stroke-width="2"
  stroke-linecap="round"
  stroke-linejoin="round"
>
  <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
</svg>
```

```html example label="In Button" hint="A loading button is a busy button: aria-busy=&quot;true&quot; plus a .spinner child, in any variant - the spinner takes the button's text color and keeps turning. The last one is disabled as well: button.css deliberately freezes a disabled button's spinner (the dimmed button already says 'pending', a wheel spinning on a control you can't use would say 'working')."
<div class="flex flex-wrap items-center gap-3">
  <button class="btn" data-variant="default" aria-busy="true">
    <svg
      class="spinner"
      data-size="sm"
      aria-hidden="true"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      stroke-width="2"
      stroke-linecap="round"
      stroke-linejoin="round"
    >
      <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
    </svg>
    Saving…
  </button>
  <button class="btn" data-variant="secondary" aria-busy="true">
    <svg
      class="spinner"
      data-size="sm"
      aria-hidden="true"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      stroke-width="2"
      stroke-linecap="round"
      stroke-linejoin="round"
    >
      <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
    </svg>
    Loading…
  </button>
  <button class="btn" data-variant="outline" aria-busy="true">
    <svg
      class="spinner"
      data-size="sm"
      aria-hidden="true"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      stroke-width="2"
      stroke-linecap="round"
      stroke-linejoin="round"
    >
      <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
    </svg>
    Syncing…
  </button>
  <button class="btn" data-variant="ghost" aria-busy="true">
    <svg
      class="spinner"
      data-size="sm"
      aria-hidden="true"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      stroke-width="2"
      stroke-linecap="round"
      stroke-linejoin="round"
    >
      <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
    </svg>
    Refreshing…
  </button>
  <button class="btn" data-variant="destructive" aria-busy="true">
    <svg
      class="spinner"
      data-size="sm"
      aria-hidden="true"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      stroke-width="2"
      stroke-linecap="round"
      stroke-linejoin="round"
    >
      <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
    </svg>
    Deleting…
  </button>
  <button class="btn" data-variant="link" aria-busy="true">
    <svg
      class="spinner"
      data-size="sm"
      aria-hidden="true"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      stroke-width="2"
      stroke-linecap="round"
      stroke-linejoin="round"
    >
      <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
    </svg>
    Loading more…
  </button>
  <button class="btn" data-variant="default" aria-busy="true" disabled>
    <svg
      class="spinner"
      data-size="sm"
      aria-hidden="true"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      stroke-width="2"
      stroke-linecap="round"
      stroke-linejoin="round"
    >
      <path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
    </svg>
    Disabled - frozen
  </button>
</div>
```

<SourceFiles component="spinner" section="css">
  <SourceNote for="css">Styles for the spinner component. Uses design tokens for colors, spacing, and radius.</SourceNote>
</SourceFiles>

</DocPage>
