uimaxxer

Tilt card

A card that leans toward your pointer, with a sheen that follows it and layers that part in depth. Drag a finger across it on touch; let go and it springs back.

npx shadcn@latest add @uimaxxer/tilt-card
Pro
yourproduct.com
A green alpine ridge under cloud, with pale scree running down its gullies

Above the treeline

Photograph by Chris Holgersson

Usage

import { TiltCard, TiltLayer } from "@/components/ui/tilt-card"

<TiltCard>
  <TiltLayer depth={-1}><img src="/ridge.jpg" alt="" /></TiltLayer>
  <TiltLayer depth={1.5}><h3>Above the treeline</h3></TiltLayer>
</TiltCard>

Props

PropTypeDefaultWhat it does
childrenReactNodeThe card face. Put TiltLayer elements inside for parallax.
maxnumber9Largest lean in degrees.
sheenbooleantrueThe light that follows the pointer.
TiltLayer depthnumber1How far a layer travels with the lean. Negative sits behind the face and is scaled up so its edges never show.

Accessibility

  • Purely visual: no role, no focus stop. Put links and buttons inside it as usual.
  • Reduced motion keeps the sheen and drops the lean, the lift and the parallax.
  • On touch it leans only while your finger drags across it; vertical scrolling still works.