Back to library
INTERACTION_089

Split Background Hover.

Two halves of the background meet in the middle on hover. Both halves scaled to 0 from the outer edges before the trigger; scaling both halves to meet at the centre once hover or focus.

CATEGORY
Buttons
COMPLEXITY
Easy
TECH
CSS
PLATFORM
Both
PERFORMANCE
Light
LIVE PLAYGROUND
CSS / CSS
/* Split Background Hover — Two halves of the background meet in the middle on hover. */
.split-background-hover {
  --dur: 420ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 60ms;
  will-change: transform, opacity;
}

.split-background-hover > * {
  opacity: 0;
  transform: translateY(14px);
  animation: split-background-hover-in var(--dur) var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* both halves scaled to 0 from the outer edges -> scaling both halves to meet at the centre */
@keyframes split-background-hover-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .split-background-hover > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
React / TSX
import { useEffect, useRef } from "react";

/** Split Background Hover — trigger: hover or focus */
export function SplitBackgroundHover({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
      el.dataset["state"] = "in";
      return;
    }
    const io = new IntersectionObserver(
      ([entry]) => {
        if (entry?.isIntersecting) {
          el.dataset["state"] = "in";
          io.unobserve(el);
        }
      },
      { threshold: 0.2 },
    );
    io.observe(el);
    return () => io.disconnect();
  }, []);

  return (
    <div ref={ref} className="split-background-hover" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

INTERACTION_082CSS

Liquid Hover Button

A rounded fill rises from the bottom edge and floods the button.

Buttons / LightView
INTERACTION_001CSS

Premium Button Lift

Weightless 2px rise with an edge highlight on hover.

Buttons / LightView
INTERACTION_002CSS

Shine Sweep Button

A diagonal chrome glint travels across the surface on hover.

Buttons / LightView
INTERACTION_004CSS

Sliding Arrow

Directional arrow that translates on hover.

Buttons / LightView