Loading effect…
Loading preview…
cards · react · free
A card that tilts in 3D toward the pointer on hover.
import { TiltCard } from "@/components/znverse/tilt-card/TiltCard";
<TiltCard maxTilt={10} perspective={900}>
Your content
</TiltCard>npx znverse add tilt-card"use client";
import {
useCallback,
useEffect,
useRef,
useState,
type CSSProperties,
type PointerEvent,
type ReactNode,
} from "react";
type TiltCardProps = {
children?: ReactNode;
className?: string;
maxTilt?: number;
perspective?: number;
};
export function TiltCard({A card that tilts in 3D toward the pointer on hover.
Copy src/TiltCard.tsx into your React project. No extra dependencies.
import { TiltCard } from "./TiltCard";
export function Example() {
return (
<TiltCard>
<h3>Hover me</h3>
<p>Subtle perspective tilt follows the pointer.</p>
</TiltCard>
);
}| Prop | Type | Default | What it does |
|---|---|---|---|
maxTilt | number | 10 | Largest tilt in degrees at the card edge |
perspective | number | 900 | Perspective distance in pixels; lower looks deeper |
className | string | Extra class on the card |
"use client")perspective + rotateX / rotateY from pointer positionprefers-reduced-motion (no tilt)