Vue 3 Spinners

1.3.3 · active · verified Sun Apr 19

Vue 3 Spinners is a collection of lightweight, customizable loading spinner components specifically designed for Vue 3 applications. Currently at version 1.3.3, it provides a variety of visually appealing spinners, many of which are derived from Quasar's spinner components and a Vue port of React Spinners. The library is actively maintained, with updates released as new features or bug fixes are introduced, though without a strict release cadence. Key differentiators include its pure Vue component implementation, support for both global and individual component registration, and extensive customization options via props like `color`, `size`, `height`, `width`, `radius`, and `margin`, allowing developers to integrate animated loading indicators seamlessly into their user interfaces. It aims to provide a performant and flexible solution for showing progress or loading states without external CSS frameworks.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and conditionally render a specific spinner (`VueSpinnerBars`) in a Vue 3 component using `<script setup>`, simulating a data loading process. It showcases basic prop usage for size and color.

<!-- src/components/MyLoadingComponent.vue -->
<template>
  <div v-if="isLoading" class="loading-overlay">
    <VueSpinnerBars :size="spinnerSize" :color="spinnerColor" />
    <p class="loading-text">Loading data...</p>
  </div>
  <div v-else>
    <!-- Your loaded content here -->
    <p>Data loaded successfully!</p>
    <button @click="simulateLoading">Reload Data</button>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { VueSpinnerBars } from 'vue3-spinners';

const isLoading = ref(true);
const spinnerSize = ref(50); // in pixels
const spinnerColor = ref('#42b983'); // Vue green

const simulateLoading = () => {
  isLoading.value = true;
  // Simulate an asynchronous operation (e.g., API call)
  setTimeout(() => {
    isLoading.value = false;
  }, 2000);
};

onMounted(() => {
  simulateLoading(); // Trigger loading on component mount
});
</script>

<style scoped>
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 15px;
  background-color: #f0f0f0;
  border-radius: 8px;
  margin-top: 20px;
}
.loading-text {
  font-family: sans-serif;
  color: #333;
  font-size: 1.1em;
}
button {
  padding: 10px 20px;
  font-size: 1em;
  color: white;
  background-color: #42b983;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin-top: 20px;
}
button:hover {
  background-color: #368a6f;
}
</style>

view raw JSON →