3D Card Effect
- Source
- Aceternity UI ↗
- Author
- Aceternity UI
- Licence
- Aceternity UI licence (free component)
Loading…
A card tilts toward the pointer while its layers lift off at different depths.
Code
"use client";
import React from "react";
import { CardBody, CardContainer, CardItem } from "@/lab/aceternity/ui/3d-card";
import { Fit } from "./_fit";
export default function ThreeDCardDemo() {
return (
<Fit width={560} height={560}>
<CardContainer className="inter-var" containerClassName="h-full w-full py-0">
<CardBody className="bg-gray-50 relative group/card dark:hover:shadow-2xl dark:hover:shadow-emerald-500/[0.1] dark:bg-black dark:border-white/[0.2] border-black/[0.1] w-[30rem] h-auto rounded-xl p-6 border">
<CardItem translateZ="50" className="text-xl font-bold text-neutral-600 dark:text-white">
Make things float in air
</CardItem>
<CardItem
as="p"
translateZ="60"
className="text-neutral-500 text-sm max-w-sm mt-2 dark:text-neutral-300"
>
Hover over this card to unleash the power of CSS perspective
</CardItem>
<CardItem translateZ="100" className="w-full mt-4">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src="https://images.unsplash.com/photo-1441974231531-c6227db76b6e?q=80&w=1200&auto=format&fit=crop&ixlib=rb-4.0.3"
height="1000"
width="1000"
className="h-60 w-full object-cover rounded-xl group-hover/card:shadow-xl"
alt="thumbnail"
/>
</CardItem>
<div className="flex justify-between items-center mt-20">
<CardItem
translateZ={20}
as="span"
className="px-4 py-2 rounded-xl text-xs font-normal dark:text-white"
>
Try now →
</CardItem>
<CardItem
translateZ={20}
as="button"
className="px-4 py-2 rounded-xl bg-black dark:bg-white dark:text-black text-white text-xs font-bold"
>
Sign up
</CardItem>
</div>
</CardBody>
</CardContainer>
</Fit>
);
}
Prompt
Build "3D Card Effect", a 3d animation. What it does: A card tilts toward the pointer while its layers lift off at different depths. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS. Technique: pointer tracking. It sits on a light background, in a square frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://ui.aceternity.com/components/3d-card-effect (Aceternity UI, Aceternity UI licence (free component)).