<div class="item"></div>
@property --from-color {
  syntax: "<color>";
  initial-value: #f0f;
  inherits: false;
}

@property --to-color {
  syntax: "<color>";
  initial-value: #0ff;
  inherits: false;
}

.item {
  width: 80vw;
  height: 50px;
  border-radius: 50px;
  background: linear-gradient(to right, var(--from-color), var(--to-color));
  animation: gradient 4s linear infinite;
}

@keyframes gradient {
  0%,
  100% {
    --from-color: #f0f;
    --to-color: #0ff;
  }
  50% {
    --from-color: #00f;
    --to-color: #ff0;
  }
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: #323232;
}

@media (prefers-reduced-motion) {
  .item {
    animation: none;
  }
  .item::after {
    text-transform: none;
    font-size: 1rem;
    line-height: 1.5;
    letter-spacing: 0;
    color: #fff;
    display: block;
    background: black;
    content: "This demo has flickering gradients, we decided not to show this based on your preferences (reduced motion setting)";
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.