JSFiddle - React, Tailwind, and code Playground

Simple CSS 3 Loader

by Jennifer Perrin

HTML

<div class="loader"></div>
<div class="loader r"></div>

CSS

body { margin: 10% 0; }

.loader {
  width: 0px;
  height: 8px;
  background: linear-gradient(to left, #6E00FF, rgba(255, 255, 255, 0));
  animation: speed 1s ease-in forwards, via 1.5s ease-out forwards;
}

.r {
  animation: speed 2s cubic-bezier(1, 0.01, 0, 1) infinite, via 2s ease-out infinite;
  background: linear-gradient(to left, #00FFBA, rgba(255, 255, 255, 0));
}

@keyframes speed {
  0% {
    width: 0px;
  }
  100% {
    width: 100%;
  }
}
@keyframes via {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}