Un anneau qui tourne pour dire qu'il se passe quelque chose. Il occupe la boîte d'une icône et en peint la quantité d'encre, si bien qu'il se glisse dans un bouton ou une ligne de texte à la place d'un glyphe.
size est un nombre de pixels, et il nomme la boîte qu'occupe l'indicateur et non le diamètre de l'anneau. Sans lui, la boîte mesure 1em et suit le texte environnant.
vue
Chargement… Follows small text
Chargement… Follows large text
Chargement… 32 pixels, whatever the text does
<script setup lang="ts">
import { VSpinner } from 'vectis-ui'
</script>
<template>
<div class="demo">
<!-- With no size the box measures 1em, so the spinner follows the text around it:
a container that sets a font-size sizes it without being told anything, which
is how it stays proportionate inside a button. -->
<p class="small"><VSpinner /> Follows small text</p>
<p class="large"><VSpinner /> Follows large text</p>
<!-- `size` is a number of pixels, and it is the BOX the spinner occupies, not the
diameter of the ring: the ring is drawn a little smaller inside it, at the
proportion an icon paints its ink at. -->
<p><VSpinner :size="32" /> 32 pixels, whatever the text does</p>
</div>
</template>
<style scoped>
.demo {
display: grid;
gap: var(--vectis-space-4);
}
.demo p {
display: flex;
align-items: center;
gap: var(--vectis-space-3);
margin: 0;
}
.small {
font-size: var(--vectis-text-body-sm-size);
}
.large {
font-size: var(--vectis-text-heading-3-size);
}
</style>
Couleur
Il n'y a pas de prop de couleur : l'anneau est peint en currentcolor, il prend donc la couleur du texte où il se trouve.
vue
Chargement… The colour of the text it sits in
Sending Sending
Retrying Retrying
<script setup lang="ts">
import { VSpinner } from 'vectis-ui'
</script>
<template>
<div class="demo">
<!-- There is no colour prop: the ring is painted in `currentcolor`, so it takes
the colour of the text around it. Set `color` on the spinner or on anything
above it, and it follows. -->
<p><VSpinner /> The colour of the text it sits in</p>
<p class="accent"><VSpinner label="Sending" /> Sending</p>
<p class="danger"><VSpinner label="Retrying" /> Retrying</p>
</div>
</template>
<style scoped>
.demo {
display: grid;
gap: var(--vectis-space-3);
}
.demo p {
display: flex;
align-items: center;
gap: var(--vectis-space-3);
margin: 0;
}
.accent {
color: var(--vectis-color-accent-text);
}
.danger {
color: var(--vectis-color-danger-text);
}
</style>
À la place d'une icône
La boîte est celle d'une icône : un VIcon et un VSpinner de même taille sont donc interchangeables. C'est ce qui permet à VButton, VInput, VTextarea et VCombobox d'en dessiner un à la taille du glyphe qu'il remplace.
vue
Searching the archive
Chargement… Searching the archive
Chargement…
<script setup lang="ts">
import { VButton, VIcon, VInput, VSpinner } from 'vectis-ui'
import { search } from 'vectis-ui/icons'
</script>
<template>
<div class="demo">
<!-- The spinner occupies an icon's box and paints an icon's amount of ink, so one
stands in for the other with nothing shifting on the line. A VIcon and a
VSpinner given the same size are interchangeable, box for box. -->
<p><VIcon :name="search" /> Searching the archive</p>
<p><VSpinner /> Searching the archive</p>
<!-- Which is what lets the controls draw their own: they set the icon size and get
a spinner the size of the glyph it replaces, with no ratio of their own. -->
<VButton class="control" loading>Saving</VButton>
<VInput class="control" label="Reference" model-value="INV-2481" loading />
</div>
</template>
<style scoped>
.demo {
display: grid;
justify-items: start;
gap: var(--vectis-space-4);
}
.demo p {
display: flex;
align-items: center;
gap: var(--vectis-space-3);
margin: 0;
}
.control {
inline-size: 14rem;
}
</style>
API
Props
Prop
Type
Défaut
size
number | string
aucune
Une taille en pixels, en nombre ou en chaîne numérique, comprise exactement comme celle de VIcon : c'est la BOÎTE qu'occupe l'indicateur, pas le diamètre de l'anneau, dessiné un peu plus petit à l'intérieur. Sans elle, la boîte mesure 1em et suit la taille du texte alentour, ce qui garde l'indicateur proportionné dans un bouton sans rien avoir à lui dire.
label
string
aucune
Ce que les lecteurs d'écran annoncent pendant qu'il tourne. Il retombe sur le dictionnaire du design system, dans la langue courante.