Veil UI
Components

Loading Overlay

A translucent surface that blocks interaction while work finishes.

Installation

$ npx veil-ui@latest add loading-overlay

Usage

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

PropTypeDefaultDescription
visiblebooleantrueUnmounts the overlay when false.
labelstring"Loading"Status text announced by the spinner.
fullscreenbooleanfalseCovers 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 relative positioning 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>

On this page