Skip to content
VenusUI
Get started

Animated Card

A card that tilts in 3D toward the pointer with spring physics.

Preview

Installation

npx shadcn@latest add @venusui/animated-card

Run this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.

Files added to your project

Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.

  • @/components/ui/animated-card.tsx

Usage

The code behind the preview above.

animated-card-demo.tsx

import { AnimatedCard } from "@/components/ui/animated-card"

export default function AnimatedCardDemo() {
  return (
    <AnimatedCard className="w-full max-w-sm p-6">
      <p className="font-mono text-xs uppercase tracking-widest text-muted-foreground">Pro plan</p>
      <p className="mt-3 text-3xl font-semibold tracking-tight">
        $24<span className="text-base font-normal text-muted-foreground">/month</span>
      </p>
      <p className="mt-2 text-sm text-muted-foreground">Hover with a mouse to tilt the card.</p>
    </AnimatedCard>
  )
}

API reference

PropTypeDefaultDescription
maxTiltnumber8Maximum tilt on each axis, in degrees.
hoverScalenumber1.02Scale while hovered. Set to 1 to turn scaling off.

All motion.div props (HTMLMotionProps<"div">), including className, style, initial, animate and event handlers.

Requirements

  • The motion package. The CLI installs it for you.
  • React 19 and Tailwind CSS v4, with a cn helper at @/lib/utils.

Customization

  • Make the tilt subtler or stronger with maxTilt, e.g. maxTilt={4}.
  • The spring is set by the SPRING constant at the top of the file (stiffness, damping, mass). The code lives in your project, so edit it directly.
  • Your own onPointerMove and onPointerLeave handlers still run. The card calls them before updating the tilt.

Accessibility

  • Tilt and scale are turned off when the user prefers reduced motion.
  • Tilt follows mouse input only, so it never interferes with touch scrolling.

Troubleshooting

The card doesn’t tilt on a phone or tablet.
This is intended. Tilt only responds to a mouse.
Nothing moves at all.
Check the reduced-motion setting of your operating system. The card stays still while it is on.
Module not found: Can't resolve 'motion/react'.
Run npm install motion. The CLI does this automatically; a manual install needs it.
Unknown registry "@venusui"
Your shadcn CLI couldn’t find the namespace in the shadcn registry index. Use the latest CLI (npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.
No components.json found
Run npx shadcn@latest init in your project first.
Loading preview

Stacked cards with the next ones peeking out; Next sends the top card to the back.

Loading preview

Envelope

Interactive

A sealed envelope that opens on hover or click: the flap folds back and the letter slides out.

Loading preview

A two-sided card that turns over in 3D, by button or on hover.