Components
Spinner
An animated indicator for work in progress.
Installation
$ npx veil-ui@latest add spinnerUsage
import { Spinner } from "@/components/ui/spinner";
<Spinner />;Examples
Basic
Loading
Sizes
LoadingLoadingLoading
Inside a button
Keep the button's accessible name stable while it is busy; the spinner adds screen-reader-only state text instead of replacing the label.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "sm" | "default" | "lg" | "default" | Icon size: 16, 20 or 24px. |
| label | string | "Loading" | Screen-reader-only status text. |
| ...props | React.ComponentProps<"span"> | — | All native span attributes. |
Accessibility
- Renders a
role="status"live region, so the label is announced politely. - The icon itself is
aria-hidden; the status text comes fromlabel. - Pass a specific
labelsuch as “Deploying” when the spinner represents a named task.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add spinner --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { Loader2 } from "lucide-vue-next";
import { computed } from "vue";
import { cn } from "@/lib/utils";
import { spinnerVariants, type SpinnerVariants } from "./variants";
const props = withDefaults(
defineProps<{
class?: string;
size?: SpinnerVariants["size"];
label?: string;
}>(),
{ label: "Loading" },
);
const iconClasses = computed(() => spinnerVariants({ size: props.size }));
</script>
<template>
<span
data-slot="spinner"
role="status"
:class="cn('inline-flex items-center justify-center', props.class)"
>
<Loader2 aria-hidden="true" :class="iconClasses" />
<span class="sr-only">{{ label }}</span>
</span>
</template>