AI CSS Animations

Radial Glow Fill Button

A soft-edged radial fill blooms up from below the button and leaves a lighter glow at the bottom center. The radius is a registered @property, so the feathered edge travels smoothly.

Also known as: radial gradient fill hover, soft radial fill, glow from below button.

HTML

<button class="hfx-radial-glow-fill">Go live</button>

CSS

@property --hfx-radial-glow-fill-r {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}
.hfx-radial-glow-fill {
  --c: var(--hfx-color, #3b82f6);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.75em;
  border-radius: 0.5em;
  font: 600 var(--hfx-size, 16px)/1.2 system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid var(--c);
  background: transparent;
  color: var(--c);
  transition: color 0.25s ease 0.2s;
}
.hfx-radial-glow-fill::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(
    circle at 50% 130%,
    color-mix(in srgb, var(--c) 45%, #fff) 0,
    var(--c) calc(var(--hfx-radial-glow-fill-r) * 0.5),
    var(--c) calc(var(--hfx-radial-glow-fill-r) * 0.75),
    transparent var(--hfx-radial-glow-fill-r)
  );
  transition: --hfx-radial-glow-fill-r 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.hfx-radial-glow-fill:is(:hover, :focus-visible) {
  background-color: var(--c); /* hides the hairline where the fill meets the border */
  color: #fff;
  transition: color 0.25s ease 0.2s, background-color 0s 0.6s;
}
.hfx-radial-glow-fill:is(:hover, :focus-visible)::before { --hfx-radial-glow-fill-r: 150%; }

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

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