AI CSS Animations

Shimmer Button

A solid button that catches a streak of light every few seconds, no hover needed. The streak is one gradient pseudo-element that slides across and then waits, so the pause reads as a glint.

Also known as: shiny button css, css button shine animation, shimmer effect button.

HTML

<button class="btn-shimmer" type="button">Upgrade to Pro</button>

CSS

.btn-shimmer {
  --c: var(--btn-color, #3b82f6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.6em;
  border: 0;
  border-radius: 0.6em;
  font: 600 var(--btn-size, 18px)/1.1 system-ui, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
  padding: 0.85em 1.9em;
  border-radius: 0.7em;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 88%, #fff), color-mix(in srgb, var(--c) 80%, #000));
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 0.45em 1em -0.4em color-mix(in srgb, var(--c) 85%, transparent);
  transition: transform 0.15s ease;}
.btn-shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 36%, rgba(255, 255, 255, 0.25) 44%, rgba(255, 255, 255, 0.7) 50%, rgba(255, 255, 255, 0.25) 56%, transparent 64%);
  transform: translateX(-100%);
  animation: btn-shimmer-sweep 3.2s cubic-bezier(0.45, 0, 0.25, 1) infinite;
  pointer-events: none;
}
.btn-shimmer:active { transform: scale(0.97); }
@keyframes btn-shimmer-sweep {
  0%        { transform: translateX(-100%); }
  40%, 100% { transform: translateX(100%); }
}

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

Customizing this snippet

  • Color: set --btn-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --btn-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 18px.
  • 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 buttons