# Loading Overlay

> A frosted overlay with a spinner that covers any card or section while it has aria-busy set.

- Category: [CSS Loaders & Spinners](https://copy-css.com/category/loaders)
- Tags: backdrop-filter, blur, card, aria-busy, spinner
- Live preview: https://copy-css.com/snippets/loading-overlay
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<section class="overlay-panel" aria-busy="true">
  <h3>Monthly report</h3>
  <p>Revenue grew 12% compared with last month, led by annual plans.</p>
  <div class="loading-overlay" role="status" aria-label="Loading"></div>
</section>
```

## CSS

```css
.overlay-panel {
  position: relative;
  width: min(100%, 280px);
  padding: 20px;
  border-radius: 16px;
  background: #fff;
  color: #334155;
  font: 15px/1.5 system-ui, sans-serif;
  box-shadow: 0 4px 16px #0f172a14;
}

.overlay-panel h3 {
  margin: 0 0 6px;
  color: #0f172a;
  font-size: 17px;
}

.overlay-panel p {
  margin: 0;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  border-radius: inherit;
  background: #ffffffa6;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* Show the overlay only while the section is busy */
[aria-busy="true"] > .loading-overlay {
  display: grid;
}

.loading-overlay::after {
  content: "";
  width: 32px;
  height: 32px;
  border: 3px solid #cbd5e1;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: loading-overlay-spin 0.8s linear infinite;
}

@keyframes loading-overlay-spin {
  to { transform: rotate(1turn); }
}

@media (prefers-reduced-motion: reduce) {
  .loading-overlay::after { animation-duration: 2s; }
}
```

## Notes

- This CSS Loading Overlay is 54 lines of pure CSS (1.0 KB) with no JavaScript and no dependencies. It uses keyframe animations, transforms, box shadows and backdrop filters.
- backdrop filters: Includes the -webkit- prefix for older Safari.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
