AI CSS Animations

Ink Bleed Button

Two blots of ink spread from opposite corners with ragged, living edges and soak the whole button. An inline SVG turbulence filter roughens the edges of two growing circles.

Also known as: ink spread hover, watercolor fill button, ink blot fill.

HTML

<button class="hfx-ink-bleed"><span class="hfx-ink-bleed-ink" aria-hidden="true"></span>Send message<svg class="hfx-ink-bleed-defs" aria-hidden="true" focusable="false"><filter id="hfx-ink-bleed-edge"><feTurbulence type="fractalNoise" baseFrequency="0.045" numOctaves="2" seed="7"/><feDisplacementMap in="SourceGraphic" scale="16" xChannelSelector="R" yChannelSelector="G"/></filter></svg></button>

CSS

.hfx-ink-bleed {
  --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.2s ease 0.3s;
}
.hfx-ink-bleed-defs {
  position: absolute;
  width: 0;
  height: 0;
}
/* oversized so the displaced edge never pulls in blank pixels at the border */
.hfx-ink-bleed-ink {
  position: absolute;
  inset: -0.8em;
  z-index: -1;
  filter: url(#hfx-ink-bleed-edge);
}
.hfx-ink-bleed-ink::before,
.hfx-ink-bleed-ink::after {
  content: "";
  position: absolute;
  width: 140%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--c);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.45s cubic-bezier(0.55, 0, 1, 0.45);
}
.hfx-ink-bleed-ink::before {
  left: 0.8em;
  top: calc(100% - 0.8em);
}
.hfx-ink-bleed-ink::after {
  left: calc(100% - 0.8em);
  top: 0.8em;
}
.hfx-ink-bleed:is(:hover, :focus-visible) {
  background-color: var(--c); /* hides the hairline where the fill meets the border */
  color: #fff;
  transition: color 0.2s ease 0.35s, background-color 0s 1s;
}
.hfx-ink-bleed:is(:hover, :focus-visible) .hfx-ink-bleed-ink::before,
.hfx-ink-bleed:is(:hover, :focus-visible) .hfx-ink-bleed-ink::after {
  transform: translate(-50%, -50%) scale(1);
  transition: transform 0.9s cubic-bezier(0.45, 0, 0.25, 1);
}
.hfx-ink-bleed:is(:hover, :focus-visible) .hfx-ink-bleed-ink::after { transition-delay: 0.12s; }

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