asafefe.dev

Tilt Card

A card that tilts in 3D toward the cursor on a spring, with a soft light glare.

motionutils@soultel/use-reduced-motion-safe

Tilt me

Follows your cursor in 3D

Installation

$ pnpm dlx shadcn@latest add @soultel/tilt-card

No namespace set up? npx shadcn@latest add https://asafefe.dev/r/tilt-card.json works too.

Manual installation
  1. 1. Install the dependencies.
    terminal1 lines
    npm install motion
  2. 2. Copy the source from the Code tab into components/tilt-card.tsx.

Usage

example.tsx9 lines
import { TiltCard } from "@/components/tilt-card"

export function Example() {
  return (
    <TiltCard className="w-64 p-6">
      <p>Hover to tilt</p>
    </TiltCard>
  )
}

Props

PropTypeDefaultDescription
intensitynumber10Max tilt in degrees.
glarebooleantrueShow the moving highlight.