Components
Loading Overlay
A translucent surface that blocks interaction while work finishes.
Installation
$ npx veil-ui@latest add loading-overlayUsage
import { LoadingOverlay } from "@/components/ui/loading-overlay";
<div className="relative min-h-40">
<LoadingOverlay label="Saving changes" />
</div>;Examples
Basic
Recent activity
Loading
Custom label
Syncing records…
Syncing records
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| visible | boolean | true | Unmounts the overlay when false. |
| label | string | "Loading" | Status text announced by the spinner. |
| fullscreen | boolean | false | Covers the viewport instead of the nearest positioned ancestor. |
Accessibility
- Sets
aria-busy="true"on the overlay and announces the label through the spinner's status role. - The visible text is hidden from screen readers to avoid double announcements.
- Give the container
relativepositioning for the default overlay.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add loading-overlay --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { Spinner } from "@/components/ui/spinner";
import { cn } from "@/lib/utils";
const props = withDefaults(
defineProps<{
class?: string;
visible?: boolean;
label?: string;
fullscreen?: boolean;
}>(),
{ visible: true, label: "Loading", fullscreen: false },
);
</script>
<template>
<div
v-if="props.visible"
data-slot="loading-overlay"
aria-busy="true"
:class="
cn(
'flex items-center justify-center bg-background/80 backdrop-blur-sm',
props.fullscreen ? 'fixed inset-0 z-50' : 'absolute inset-0 z-10',
props.class,
)
"
>
<div class="flex flex-col items-center gap-2 text-sm text-muted-foreground">
<Spinner size="lg" :label="props.label" />
<span aria-hidden="true">{{ props.label }}</span>
</div>
</div>
</template>