INTERACTION_093CSS
Expandable Card
A card grows in place to reveal its detail without a page change.
Cards / LightView
Two states swap inside the same card frame. State A visible, state B rotated out on the Y axis before the trigger; rotating the card face 180deg to show the opposite state once toggling the switch control.
/* Comparison Card Transition — Two states swap inside the same card frame. */
.comparison-card-transition {
--dur: 620ms;
--ease: cubic-bezier(0.22, 1, 0.36, 1);
--stagger: 60ms;
will-change: transform, opacity;
}
.comparison-card-transition > * {
opacity: 0;
transform: translateY(14px);
animation: comparison-card-transition-in var(--dur) var(--ease) forwards;
animation-delay: calc(var(--i, 0) * var(--stagger));
}
/* state A visible, state B rotated out on the Y axis -> rotating the card face 180deg to show the opposite state */
@keyframes comparison-card-transition-in {
to {
opacity: 1;
transform: none;
filter: none;
}
}
@media (prefers-reduced-motion: reduce) {
.comparison-card-transition > * {
opacity: 1;
transform: none;
animation: none;
}
}import { useEffect, useRef } from "react";
/** Comparison Card Transition — trigger: toggling the switch control */
export function ComparisonCardTransition({ 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="comparison-card-transition" data-state="out">
{children}
</div>
);
}A card grows in place to reveal its detail without a page change.
The card content shifts subtly with pointer position.
The card expands into a modal from its own position.
Move the cursor across this surface.
A soft radial light follows the cursor across the surface.