iPhone 3D mockup
A 3D iPhone mockup to beautifully showcase your app on landing pages. It is built purely with React and CSS with no external dependencies, keeping your site fast.

API usage
components/iphone-3d-mockup.demo.tsx
"use client";
import { useSpring, useTransform } from "motion/react";
import { motion } from "motion/react";
import Image from "next/image";
import { IPhone3DMockup, IPhone3DMockupScreen } from "./iphone-3d-mockup";
import appStoreScreenshot from "@/public/demo/iphone-3d-mockup/app-store-screenshot.jpeg";
const MotionIPhone3DMockup = motion.create(IPhone3DMockup); // Creating a motion-enhanced version of the IPhone3DMockup component
export function IPhone3DMockupDemo() {
const mouseXProgress = useSpring(0.1);
const mouseYProgress = useSpring(0.9);
const rotateX = useTransform(mouseYProgress, [0, 1], ["25deg", "-25deg"]);
const rotateY = useTransform(mouseXProgress, [0, 1], ["-35deg", "35deg"]);
const handleMouseMove = (e: any) => {
const { width, height, x, y } = e.target.getBoundingClientRect();
const mouseX = e.clientX;
const mouseY = e.clientY;
const relativeX = (mouseX - x) / width;
const relativeY = (mouseY - y) / height;
mouseXProgress.set(relativeX);
mouseYProgress.set(relativeY);
};
[];
const handleMouseLeave = () => {
mouseXProgress.set(0.5);
mouseYProgress.set(0.5);
};
return (
<div
className="py-20"
onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave}
>
<MotionIPhone3DMockup
style={{ rotateX, rotateY }}
className="pointer-events-none mx-auto"
>
<IPhone3DMockupScreen>
<Image src={appStoreScreenshot} alt="" className="h-full" />
</IPhone3DMockupScreen>
</MotionIPhone3DMockup>
</div>
);
}
Installation
CLI (recommended)
1
Run the command below to add the component to your project.
It will also generate the required base stylesheet if one doesn't already exist and guide you through setting up the import alias
@/components/... if it isn't already configured.pnpm dlx shadcn@latest add https://100xui.com/components/iphone-3d-mockup.jsonManual
1
pnpm add clsx tailwind-merge2
100xui
components/iphone-3d-mockup.tsx
3
API reference
<IPhone3DMockup/><IPhone3DMockupScreen/>
| Props | Type | Description | Default value |
|---|---|---|---|
props | | Any standard React div props, like children, id, style or className, which will be applied directly to the component's root element. | |