Skip to content

Spinner

A turning circle that says something is loading. Same markup and props in every style: switch the style in the header to see it change.

Sizes and colour

On its own, a spinner has role="status" and a label. It takes the text colour, or the accent with primary.

spinner-basic.html
<span class="vin-spinner vin-spinner--sm" role="status" aria-label="Loading"></span>
<span class="vin-spinner" role="status" aria-label="Loading"></span>
<span class="vin-spinner vin-spinner--lg" role="status" aria-label="Loading"></span>
<span class="vin-spinner vin-spinner--lg vin-spinner--primary" role="status" aria-label="Loading"></span>

In a button

Put a small spinner before the label and say what's happening ("Saving…"). Disable the button while it works.

spinner-button.html
<button type="button" class="vin-btn" disabled>
  <span class="vin-spinner vin-spinner--sm" aria-hidden="true"></span>
  Saving…
</button>
<button type="button" class="vin-btn vin-btn--outline" disabled>
  <span class="vin-spinner vin-spinner--sm" aria-hidden="true"></span>
  Loading more
</button>

With a message

Loading shows a spinner with text, on the page or inside a card.

Loading results…
Fetching invoices…
spinner-with-text.html
<div style="display: grid; gap: 20px; justify-items: center; width: 100%; max-width: 300px">
  <div class="vin-loading" role="status">
    <span class="vin-spinner" aria-hidden="true"></span>
    Loading results…
  </div>
  <div class="vin-card" style="width: 100%">
    <div class="vin-card__body" style="display: grid; place-items: center; min-height: 120px">
      <div class="vin-loading" role="status">
        <span class="vin-spinner vin-spinner--primary" aria-hidden="true"></span>
        Fetching invoices…
      </div>
    </div>
  </div>
</div>

Installation

React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:

Terminal
npx @vinish/ui add spinner
React
import { Spinner, Loading } from "@/components/vin/spinner";
Vue
import Spinner, { Loading } from "@/components/vin/spinner.vue";
Svelte
import Spinner from "$lib/components/vin/spinner.svelte";
import Loading from "$lib/components/vin/spinner-loading.svelte";

The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.

Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.

API

From spec/spinner.json, which every framework version is tested against.

PropValuesDefaultIn HTML
sizesmmdlgmdvin-spinner--{value}
variant
Text colour, or the accent colour.
currentprimarycurrentvin-spinner--primary
label
What screen readers hear. Leave it out (decorative) when text next to the spinner says it.
stringLoadingrole="status" aria-label="…", or aria-hidden="true"
Loading
A spinner with a message, announced politely.
children—<div class="vin-loading" role="status">

Parts

React, Vue, SvelteHTML classes
<Spinner><Loading>.vin-spinner.vin-spinner--sm.vin-spinner--lg.vin-spinner--primary.vin-loading

Accessibility

  • A spinner on its own has role="status" and a label, so screen readers say "Loading".
  • Next to text that already says it, the spinner is hidden (aria-hidden) so nothing is said twice.
  • With reduced motion the spinner turns slowly; with motion off it stops (still shown as an arc).