JSFiddle - React, Tailwind, and code Playground

HTML

<button class="rgbutton">
  Hover Me
</button>

CSS

button {
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  margin: 0.5rem;
  cursor: pointer;
}

.rgbutton {
  --borderWidth: 3px;
  position: relative;
  overflow: clip;
  overflow-clip-margin: var(--borderWidth);
}

.rgbutton:hover::after {
  content: '';
  position: absolute;
  inset: 0;
  left: calc(-2 * var(--borderWidth));
  margin: auto;
  width: calc(100% + 4 * var(--borderWidth));
  aspect-ratio: 1;
  background: conic-gradient(red, orange, yellow, lime, aqua, blue, magenta, red);
  z-index: -1;
  animation: move 4s linear infinite;
}

@keyframes move {
  to {
    rotate: 360deg;
  }
}