3D Tilt Card
A card that tilts in 3D toward the cursor with perspective. Springs back on leave.
import { motion, useMotionValue, useTransform } from "framer-motion";
export function TiltCard({ children }) {
const x = useMotionValue(0); const y = useMotionValue(0);
const rx = useTransform(y, [-60, 60], [12, -12]);
const ry = useTransform(x, [-60, 60], [-12, 12]);
return (
<motion.div
style={{ rotateX: rx, rotateY: ry, transformPerspective: 700 }}
onMouseMove={(e) => { const r = e.currentTarget.getBoundingClientRect(); x.set(e.clientX - r.left - r.width/2); y.set(e.clientY - r.top - r.height/2); }}
onMouseLeave={() => { x.set(0); y.set(0); }}
className="rounded-2xl border border-white/10 bg-gradient-to-br from-[#1a2236] to-[#0a0e1a] p-6 text-white"
>{children}</motion.div>
);
}How it works
3D Tilt Card is a hand-built card component for React, styled with Tailwind and animated with Framer Motion — no heavy dependency tree, no 60-package install. Drop it in, keep your bundle lean, and it stays performant on real devices. It's free — copy the code above and ship it.
← Browse all components