AI CSS Animations

Pulse Ring Button

On hover a ring radiates outward from the button's edge and fades, once per second, like a sonar ping. It stops the moment the cursor leaves.

Also known as: ping button, radar button hover.

HTML

<button class="hfx-pulse-ring">Notify me</button>

CSS

.hfx-pulse-ring {
  --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;
  border: 0;
  background: var(--c);
  color: #fff;}
.hfx-pulse-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 70%, transparent);
  pointer-events: none;
}
.hfx-pulse-ring:hover::after {
  animation: hfx-pulse-ring-ping 1s ease-out infinite;
}
@keyframes hfx-pulse-ring-ping {
  to { box-shadow: 0 0 0 0.9em transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .hfx-pulse-ring, .hfx-pulse-ring *, .hfx-pulse-ring::before, .hfx-pulse-ring::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