# Top Loading Bar

> A thin glowing bar pinned to the top of the page that eases toward the end while a page loads.

- Category: [CSS Loaders & Spinners](https://copy-css.com/category/loaders)
- Tags: page load, nprogress, youtube, fixed, route change, glow
- Live preview: https://copy-css.com/snippets/top-loading-bar
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<div class="top-loading-bar" role="progressbar" aria-label="Loading page"></div>
```

## CSS

```css
.top-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 0;
  height: 3px;
  border-radius: 0 3px 3px 0;
  background: #2563eb;
  box-shadow: 0 0 8px #2563eb, 0 0 2px #2563eb;
  /* Fast at first, then slows to a crawl near the end. Remove the element when the load finishes. */
  animation: top-loading-bar-grow 8s cubic-bezier(0.1, 0.7, 0.2, 1) forwards;
}

@keyframes top-loading-bar-grow {
  0% { width: 0; }
  20% { width: 45%; }
  100% { width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .top-loading-bar { animation: none; width: 60%; }
}
```

## Notes

- This CSS Top Loading Bar is 23 lines of pure CSS (0.6 KB) with no JavaScript and no dependencies. It uses keyframe animations, box shadows and reduced-motion support.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
