Tilt

A card that tilts in 3D toward the pointer and returns flat.

tilt.tsx

Installation

1

Install the packages

npm install @prequelui/react motion

@prequelui/react reuses the primitive library your components already depend on.

2

Add the component

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/tilt.json

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/tilt.json

3

Turn on the motion

npx @prequelui/cli@latest animate tilt

The CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

tilt.tsx
import { Tilt } from "@/components/prequelui/effects/tilt";

export default function Demo() {
  return (
    <Tilt maxTilt={10} perspective={800} className="size-56 rounded-2xl border p-5">
      Look at me.
    </Tilt>
  );
}
import { Tilt } from "@/components/prequelui/tilt";

export function Variant() {
  return (
    <Tilt tempo={1.2}>
      …
    </Tilt>
  );
}

Animation

The card maps the pointer position to a pair of rotations. The raw values are passed through the same spring, so the tilt eases in, retargets while the pointer moves and returns flat when it leaves. Perspective is set on the transform itself so the card keeps its own layout.

  • Spring: stiffness 300, damping 25, mass 0.5.
  • Maximum tilt is 10° by default and perspective is 800.
  • The pointer is read from the element rect and normalised to −1…1.
  • Reduced motion settles both rotations at zero.
spring 300 / 25max 10°perspective 800pointer normalised

API Reference

Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.

Tilt

PropTypeDefault
maxTiltnumber10
perspectivenumber800
transitionSpringOptions300 / 25 / 0.5
classNamestring—

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026