AI CSS Animations

Gradient Shadow Button

A gradient button that casts a blurred copy of itself as its shadow. On hover the button rises while the colored shadow spreads and drops, so it reads as glow and depth at once.

Also known as: colored shadow button, blurred gradient glow, glow shadow button css.

HTML

<button class="btn-gradient-shadow">Try it free</button>

CSS

.btn-gradient-shadow {
  --c: var(--btn-color, #3b82f6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font: 600 var(--btn-size, 18px)/1.2 system-ui, sans-serif;
  cursor: pointer;
  position: relative;
  isolation: isolate;
  padding: 0.8em 1.8em;
  border: 0;
  border-radius: 0.7em;
  background: transparent;
  color: #fff;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);}
.btn-gradient-shadow::before,
.btn-gradient-shadow::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 45%, #d946ef), color-mix(in srgb, var(--c) 30%, #f43f5e));
}
.btn-gradient-shadow::before {
  filter: blur(0.8em);
  opacity: 0.45;
  transform: translateY(0.3em) scale(0.85, 0.7);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
}
.btn-gradient-shadow:is(:hover, :focus-visible) { transform: translateY(-0.2em); }
.btn-gradient-shadow:is(:hover, :focus-visible)::before {
  opacity: 0.85;
  transform: translateY(0.75em) scale(0.95, 0.9);
}

@media (prefers-reduced-motion: reduce) {
  .btn-gradient-shadow, .btn-gradient-shadow *, .btn-gradient-shadow::before, .btn-gradient-shadow::after, .btn-gradient-shadow *::before, .btn-gradient-shadow *::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