Modus UI

Tilted Card

Web (React)

A 3D interactive card that physically tilts and pans relative to the cursor position.

A highly responsive 3D card utilizing Framer Motion spring physics. It dynamically calculates cursor offsets to apply localized 3D rotations, complete with an attached tooltip that flows with cursor velocity.

Red Nike Shoe

Just Do It.

Interactive 3D Hover

Installation

CLI

npx @modus-ui/cli add tilted-card

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/tilted-card.tsx.
  3. Paste the code.

Usage

tsx
import { TiltedCard } from "@/components/ui/tilted-card";

export default function Example() {
  return (
    <TiltedCard
      imageSrc="/path/to/image.jpg"
      altText="Description"
      captionText="Tooltip Content"
      containerHeight={400}
      containerWidth={300}
      imageHeight={400}
      imageWidth={300}
      rotateAmplitude={12}
      scaleOnHover={1.1}
      showTooltip={true}
      displayOverlayContent={true}
      overlayContent={
        <div className="flex h-[400px] w-[300px] flex-col justify-end rounded-xl p-6">
          <p className="text-2xl font-bold text-white">Overlay Text</p>
        </div>
      }
    />
  );
}

Props

PropTypeDefaultDescription
imageSrcstring-Image URL.
altTextstring"Tilted card image"Alt text for the image.
captionTextstring""Tooltip text that follows the cursor.
containerHeightstring | number"300px"Height of the container.
containerWidthstring | number"100%"Width of the container.
imageHeightstring | number"300px"Height of the image.
imageWidthstring | number"300px"Width of the image.
scaleOnHovernumber1.1Scale applied while hovered.
rotateAmplitudenumber14Maximum tilt in degrees.
showMobileWarningbooleanfalseShows a note that the effect needs a pointer.
showTooltipbooleantrueShows the caption tooltip.
overlayContentReact.ReactNodenullContent layered over the image.
displayOverlayContentbooleanfalseShows overlayContent.

Comments

  • No comments yet.