AI CSS Animations

Ripple Border

Rings ripple out from the border and fade, one after another, like a call coming in. Each ring is an outline on a pseudo-element with a growing outline-offset, so it keeps the rounded corners.

Also known as: border pulse animation css, double border ripple, pulse ring border.

Incoming call

HTML

<div class="bdr-ripple-border">Incoming call</div>

CSS

.bdr-ripple-border {
  --c: var(--bdr-color, #3b82f6);
  font-size: var(--bdr-size, 16px);
  position: relative;
  display: grid;
  place-items: center;
  width: 15em;
  height: 8.5em;
  border-radius: 1em;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  border: 0.12em solid var(--c);
  box-sizing: border-box;
  background: color-mix(in srgb, var(--c) 8%, #fff);
  color: color-mix(in srgb, var(--c) 45%, #111827);
}
.bdr-ripple-border::before,
.bdr-ripple-border::after {
  content: "";
  position: absolute;
  inset: -0.12em;
  border-radius: inherit;
  outline: 0.12em solid var(--c);
  pointer-events: none;
  animation: bdr-ripple-border-out 2.4s cubic-bezier(0.2, 0.6, 0.35, 1) infinite;
}
.bdr-ripple-border::after { animation-delay: -1.2s; }
@keyframes bdr-ripple-border-out {
  0%   { outline-offset: 0; opacity: 1; }
  100% { outline-offset: 1.5em; opacity: 0; }
}

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

Customizing this snippet

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