Anchor Design System

Spinner3.0

Spinner express an unspecified wait time or display the length of a process.

Installation

npm i @tryg/vue-ui-library

Usage

Install the component library as a Vue plugin. This globally registers all Anchor components.

main.js
import { createApp } from 'vue';
import { ComponentLibrary } from '@tryg/vue-ui-library';
import App from './App.vue';

const app = createApp(App);
app.use(ComponentLibrary);
app.mount('#app');
YourComponent.vue
<template>
  <anchor-spinner size="large"></anchor-spinner>
</template>

Import only the components you need for optimal bundle size.

YourComponent.vue
<script setup>
import { AnchorSpinner } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-spinner size="large"></anchor-spinner>
</template>

Note: Spinner adds Loading as aria-label by default. This is required for accessibility. You can change it by passing a loading-text or aria-label prop.

Sizes

Pass the size prop with value xsmall, small, medium, large or xlarge to display the spinner with different sizes.

<template>
  <anchor-spinner size="xsmall"></anchor-spinner>
  <anchor-spinner size="small"></anchor-spinner>
  <anchor-spinner size="medium"></anchor-spinner>
  <anchor-spinner size="large"></anchor-spinner>
  <anchor-spinner size="xlarge"></anchor-spinner>
</template>

Colors

The spinner will be colored by 'currentColor' of its parent element. If you want to set the color of the spinner specifically, you can set the text color of the parent element or directly for the Spinner.

<style>
  .color-item:nth-child(1) { color: red; }
  .color-item:nth-child(2) { color: green; }
  .color-item:nth-child(3) { color: blue; }
  .color-item:nth-child(4) { color: yellow; }
  .color-item:nth-child(5) { color: fuchsia; }
</style>
<template>
  <div class="color-item"><anchor-spinner size="xsmall"></anchor-spinner></div>
  <div class="color-item"><anchor-spinner size="small"></anchor-spinner></div>
  <div class="color-item"><anchor-spinner size="medium"></anchor-spinner></div>
  <div class="color-item"><anchor-spinner size="large"></anchor-spinner></div>
  <div class="color-item"><anchor-spinner size="xlarge"></anchor-spinner></div>
</template>

Stroke width

<template>
  <anchor-spinner stroke-width="20"></anchor-spinner>
</template>

You shouldn't change this from its default but we've included the option for the sake of flexibility.

Accessibility

  • Uses role="status" with an aria-live region (default polite, configurable to assertive or off) to announce loading state to screen readers.
  • The spinner SVG itself is hidden from screen readers using aria-hidden="true", with the loading announcement delivered through a visually hidden span element.
  • Defaults to aria-label="Loading" for the loading announcement. Customize the announcement text using the loading-text prop.
  • The aria-live prop controls the politeness level, allowing urgent loading states to interrupt screen reader output when needed.
  • The visual-only animation does not interfere with screen reader users, as the spinning motion is not conveyed assistively.

API

Spinner

Properties

PropertyAttributeDescriptionTypeDefault
ariaLivearia-liveLive region politeness. Default = 'polite' but can be overridden to 'assertive' or 'off'."assertive" | "off" | "polite"'polite'
loadingTextloading-textOPTIONAL loading text to announce when spinner is displayed. If not provided → no live region is rendered (no announcement).stringundefined
sizesizeWe recommend controlling the size of the Spinner with the parent container. Size option included for the sake of flexibility."large" | "medium" | "small" | "xlarge" | "xsmall"undefined
strokeWidthstroke-widthYou shouldn't change this from it's default but we've included the option for the sake of flexibilitynumber7

CSS Custom Properties

NameDescription
--animationDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--durationDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--end-rotationDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--pathDEPRECATED: kept for backwards compatibility, but will be removed by April 2024
--spinner-animationSet the animation properties of the spinner.
--spinner-colorSet the path color of the spinner.
--spinner-durationSet the duration of the spinner animation.
--spinner-end-rotationSet the ending rotation of the spinner.
--spinner-start-rotationSet the starting rotation of the spinner.
--start-rotationDEPRECATED: kept for backwards compatibility, but will be removed by April 2024

Dependencies

Used by

Graph

graph TD;
  anchor-button --> anchor-spinner
  style anchor-spinner fill:#f9f,stroke:#333,stroke-width:4px

Built with StencilJS

On this page