Spinner
A small turning ring for "this is working", sized to the text around it.
Install
If this is the first component in the project, set up once. This writes ermine.json and copies the theme stylesheet. The installation guide covers Vue, Nuxt and Astro.
npx ermineui initpnpm dlx ermineui inityarn dlx ermineui initbunx ermineui initThen add the component:
npx ermineui add spinnerpnpm dlx ermineui add spinneryarn dlx ermineui add spinnerbunx ermineui add spinnerThat copies 2 files into src/components/ui/spinner/. Files you already have are kept.
Use
import { Spinner } from '@/components/ui/spinner'<Alert variant="destructive">
<svg>…</svg> <!-- optional: an svg placed first becomes the icon -->
<AlertTitle>Build failed</AlertTitle>
<AlertDescription>Type error in cart/total.ts on line 42.</AlertDescription>
</Alert>
<Avatar src="/people/ines.jpg" alt="Ines Kovač">IK</Avatar>
<Progress :value="35" aria-label="Upload" /> <!-- leave value out when the amount is unknown -->
<Spinner />
<Button :loading="saving" @click="save">Save</Button> <!-- a spinner, and no second press, while saving is true -->In Nuxt, with the auto-import setting, the tags work in templates without the import. In Astro, use it inside a Vue island.
What gets copied
| File | Where it goes |
|---|---|
Spinner.vue | src/components/ui/spinner/Spinner.vue |
index.ts | src/components/ui/spinner/index.ts |
The folders are the suggested ones. ermine.json says where yours are.
Source
This is exactly what the command copies. To install by hand, create each file below and the helpers listed above.
Spinner.vue 63 lines
<script setup lang="ts">
withDefaults(
defineProps<{
/** What screen readers announce. Pass an empty string when text beside the spinner already says it. */
label?: string
size?: 'sm' | 'md' | 'lg'
}>(),
{ label: 'Loading', size: 'md' },
)
</script>
<template>
<svg
class="er-spinner"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.5"
stroke-linecap="round"
:role="label ? 'status' : undefined"
:aria-label="label || undefined"
:aria-hidden="label ? undefined : true"
:data-size="size"
>
<circle cx="12" cy="12" r="9" opacity="0.2" />
<path d="M21 12a9 9 0 0 0-9-9" />
</svg>
</template>
<style>
@layer components {
.er-spinner {
flex-shrink: 0;
width: 1rem;
height: 1rem;
animation: er-spinner-turn 0.7s linear infinite;
}
.er-spinner[data-size='sm'] {
width: 0.75rem;
height: 0.75rem;
}
.er-spinner[data-size='lg'] {
width: 1.5rem;
height: 1.5rem;
}
@keyframes er-spinner-turn {
to {
transform: rotate(360deg);
}
}
/* The turning is the whole message, so reduced motion slows it rather than stopping it. */
@media (prefers-reduced-motion: reduce) {
.er-spinner {
animation-duration: 2.5s;
}
}
}
</style>index.ts 3 lines
/** Spinner — a small turning ring for "this is working", sized to the text around it. */
export { default as Spinner } from './Spinner.vue'