Overview
Tilt Card maps the pointer position to rotateX / rotateY through springs, lifts the surface slightly and sweeps a radial glare across it. The surface preserves 3D, so children can float above it with translateZ for a parallax effect. Pointer tracking writes to motion values only — the card never re-renders while you move. Touch input and prefers-reduced-motion get a calm, flat card.
01Installation
Method 01 · Registry
CLI verifiedUses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/tilt-card.tsx and adds its dependencies.
npx shadcn@latest add https://wancraft.my/r/tilt-card.jsonMethod 02 · Copy and paste
- 1. Install the dependencies below.
- 2. Copy the source from the Code tab into
components/ui/tilt-card.tsx. - 3. Import it and adjust props.
npm install motion- Dependencies
- motion
- Peer
- react ≥ 18, tailwindcss ≥ 4
- Added
- 1 Oct 2026
- Updated
- 13 Oct 2026
02Usage
The default configuration. Change properties above to generate a tailored example in the Usage tab.
import { TiltCard } from "@/components/ui/tilt-card";
export function TiltCardExample() {
return (
<TiltCard className="w-72">
<div className="p-6">
<h3 className="text-lg font-medium">Perspective study</h3>
<p className="text-sm opacity-70">Move the pointer across the card.</p>
</div>
</TiltCard>
);
}03Props
| Prop | Type | Default | Description |
|---|---|---|---|
| tiltStrength | number | 12 | Maximum rotation in degrees at the edges. |
| spring | { stiffness: number; damping: number; mass: number } | { stiffness: 220, damping: 22, mass: 0.6 } | Spring smoothing rotation, lift and glare. |
| scale | number | 1.03 | Scale while hovered. |
| perspective | number | 900 | CSS perspective in px; lower values exaggerate depth. |
| glare | boolean | true | Show a radial reflection following the pointer. |
| glareOpacity | number | 0.35 | Peak glare opacity (0–1). |
| rounded | number | 20 | Surface corner radius in px. |
| surfaceClassName | string | white / graphite surface | Classes for the tilting surface (background, border, shadow). Passing it replaces the default surface styling. |
| className | string | — | Classes for the outer wrapper — use it for sizing. |
| children | ReactNode | — | Card content. Add [transform:translateZ(…)] to float layers above the surface. |
04Features
- 01Spring-smoothed rotateX / rotateY mapped from the pointer
- 02Pointer-following radial glare with configurable intensity
- 03preserve-3d surface so children can use translateZ for parallax depth
- 04Hit area on a non-rotating wrapper, so the tilt never jitters at the edges
- 05No React re-renders while the pointer moves
05Accessibility
- The card is a plain container — it adds no roles and does not trap focus; interactive children keep their own semantics.
- When a child receives keyboard focus, the surface shows a focus outline (:has(:focus-visible)).
- The glare layer is aria-hidden and ignores pointer events.
- Touch input never tilts the card, so scrolling is unaffected.
- With prefers-reduced-motion the card stays flat and the glare is removed.