AI CSS Animations

Shine

A glossy streak of light sweeps across the element every few seconds, like a reflection on glass. A classic for a premium badge or a sign up button. A gradient ::after slides under overflow: hidden.

Also known as: shine animation css, shine effect button, glossy light sweep.

Shine

HTML

<div class="kfa-shine">Shine</div>

CSS

.kfa-shine {
  --c: var(--kfa-color, #3b82f6);
  font-size: var(--kfa-size, 16px);
  display: grid;
  place-items: center;
  width: 5.5em;
  height: 5.5em;
  border-radius: 1em;
  background: var(--c);
  color: #fff;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  box-shadow: 0 0.6em 1.4em -0.6em color-mix(in srgb, var(--c) 70%, transparent);
  position: relative;
  overflow: hidden;
}
.kfa-shine::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgb(255 255 255 / 0.55) 48%, rgb(255 255 255 / 0.15) 56%, transparent 66%);
  transform: translateX(-110%);
  animation: kfa-shine-sweep 2.8s cubic-bezier(0.45, 0, 0.2, 1) infinite;
}
@keyframes kfa-shine-sweep {
  0% { transform: translateX(-110%); }
  36%, 100% { transform: translateX(110%); }
}

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

Customizing this snippet

  • Color: set --kfa-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --kfa-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 keyframe animations