Back to library
INTERACTION_097

Cursor Reactive Card.

The card content shifts subtly with pointer position. All layers centred before the trigger; translating each layer by a different fraction of the normalised pointer offset once pointer movement inside the card.

CATEGORY
Cards
COMPLEXITY
Intermediate
TECH
CSS + JS
PLATFORM
Desktop
PERFORMANCE
Light
LIVE PLAYGROUND
CSS / CSS
/* Cursor Reactive Card — The card content shifts subtly with pointer position. */
.cursor-reactive-card {
  --dur: 300ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 60ms;
  will-change: transform, opacity;
}

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

/* all layers centred -> translating each layer by a different fraction of the normalised pointer offset */
@keyframes cursor-reactive-card-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

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

/** Cursor Reactive Card — trigger: pointer movement inside the card */
export function CursorReactiveCard({ 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="cursor-reactive-card" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

INTERACTION_093CSS

Expandable Card

A card grows in place to reveal its detail without a page change.

Cards / LightView
INTERACTION_104CSS

Comparison Card Transition

Two states swap inside the same card frame.

Cards / LightView
SPOTLIGHT

Move the cursor across this surface.

INTERACTION_007CSS + JS

Mouse Spotlight Card

A soft radial light follows the cursor across the surface.

Cards / LightView
TILT / 6°
INTERACTION_008CSS + JS

3D Tilt Card

Perspective tilt that responds to pointer position.

Cards / MediumView