AI CSS Animations

Shine Sweep Button

A band of light passes over a solid button, like a reflection sliding across glass. The band is a translucent gradient that only moves on hover.

Also known as: glossy button hover, shimmer button, light sweep.

HTML

<button class="hfx-shine-sweep">Upgrade to Pro</button>

CSS

.hfx-shine-sweep {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7em 1.6em;
  border-radius: 0.5em;
  font: 600 1em system-ui, sans-serif;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 0;
  background: var(--c);
  color: #fff;}
.hfx-shine-sweep::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}
.hfx-shine-sweep:hover::after { transform: translateX(100%); }

@media (prefers-reduced-motion: reduce) {
  .hfx-shine-sweep, .hfx-shine-sweep *, .hfx-shine-sweep::before, .hfx-shine-sweep::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Tailwind CSS version

The same effect using Tailwind utility classes. No custom CSS or config needed.

<button class="relative overflow-hidden rounded-lg bg-blue-500 px-6 py-3 font-semibold text-white group">
  Upgrade to Pro
  <span class="absolute inset-0 -translate-x-full bg-gradient-to-r from-transparent via-white/40 to-transparent transition-transform duration-500 group-hover:translate-x-full"></span>
</button>

Customizing this snippet

  • Color: set --hfx-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hfx-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar hover effects