On this page

Spinner

Live examples of Spinner, with the exact Vue file that renders each one.

Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz.

With a label

The spinner names itself (“Loading orders”); the visible text beside it is hidden from screen readers so it is not read twice.

SpinnerInline.vue
<script setup lang="ts">
import { Spinner } from '@/components/ui/spinner'
</script>

<template>
  <!-- The spinner shows after motion.wait.spinner (1 s). Wait a moment, or reload the page to see it appear. -->
  <div class="flex items-center gap-(--bh-space-100) text-(--bh-color-text-subtle) [font:var(--bh-font-body-default)]">
    <Spinner aria-label="Loading orders" />
    <span aria-hidden="true">Loading orders…</span>
  </div>
</template>

The 1 second wait

A fast load ends before motion.wait.spinner, so no spinner flashes. A slow load shows it after 1 second.

Pick a load.
SpinnerDelay.vue
<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue'
import { Button } from '@/components/ui/button'
import { Spinner } from '@/components/ui/spinner'

// A fast load (0.5 s) finishes before the spinner's 1 s wait, so no spinner shows; a slow one (3 s) shows it.
const state = ref<'idle' | 'loading' | 'done'>('idle')
let timer: ReturnType<typeof setTimeout> | undefined

function load(ms: number) {
  clearTimeout(timer)
  state.value = 'loading'
  timer = setTimeout(() => { state.value = 'done' }, ms)
}
onBeforeUnmount(() => clearTimeout(timer))
</script>

<template>
  <div class="flex w-full max-w-120 flex-col gap-(--bh-space-150)">
    <div class="flex flex-wrap gap-(--bh-space-100)">
      <Button variant="outline" size="sm" @click="load(500)">Fast load</Button>
      <Button variant="outline" size="sm" @click="load(3000)">Slow load</Button>
    </div>
    <div
      :aria-busy="state === 'loading'"
      class="flex min-h-(--bh-size-control-large) items-center gap-(--bh-space-100) rounded-(--bh-radius-card) border-(length:--bh-border-width-default) border-(--bh-color-border) bg-(--bh-color-surface) px-(--bh-space-200) text-(--bh-color-text) [font:var(--bh-font-body-default)]"
    >
      <Spinner v-if="state === 'loading'" aria-label="Loading invoices" />
      <span v-else-if="state === 'done'">12 invoices loaded.</span>
      <span v-else class="text-(--bh-color-text-subtle)">Pick a load.</span>
    </div>
  </div>
</template>