Skip to content
VenusUI
Get started

Depth Card

A card that tilts toward the pointer while its layers rise off the surface, each to its own depth.

Preview

Installation

npx shadcn@latest add @venusui/depth-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/depth-card.tsx

Usage

The code behind the preview above.

depth-card-demo.tsx

import { ArrowRight } from "lucide-react"

import { DepthCard, DepthCardItem } from "@/components/ui/depth-card"

// Photo: Unsplash (free under the Unsplash License).
const PHOTO = "https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=900&h=560&fit=crop&auto=format&q=80"

export default function DepthCardDemo() {
  return (
    <DepthCard className="w-[min(26rem,calc(100vw-3rem))] rounded-2xl border bg-card p-6 text-card-foreground shadow-sm">
      <DepthCardItem depth={50}>
        <h3 className="text-xl font-semibold tracking-tight">Lift every layer</h3>
      </DepthCardItem>
      <DepthCardItem depth={60} className="mt-2">
        <p className="text-sm leading-6 text-muted-foreground">
          Move your pointer over the card. Each layer has its own depth, so the photo rises above the text.
        </p>
      </DepthCardItem>
      <DepthCardItem depth={100} className="relative mt-5">
        <img
          src={PHOTO}
          alt="Snowy mountain peaks rising above a sea of clouds at sunset."
          width={900}
          height={560}
          className="aspect-[16/10] w-full rounded-xl object-cover shadow-none transition-shadow duration-500 group-data-active/depth-card:shadow-2xl group-data-active/depth-card:shadow-black/25"
        />
        <DepthCardItem depth={40} className="absolute top-3 left-3">
          <span className="rounded-full bg-black/55 px-2.5 py-1 text-xs font-medium text-white backdrop-blur">Above the clouds</span>
        </DepthCardItem>
      </DepthCardItem>
      <div className="mt-6 flex items-center justify-between transform-3d">
        <DepthCardItem depth={30} x={-8}>
          <a href="#" className="inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground">
            Read the guide <ArrowRight aria-hidden="true" className="size-3.5" />
          </a>
        </DepthCardItem>
        <DepthCardItem depth={30} x={8}>
          <a href="#" className="inline-flex h-9 items-center rounded-lg bg-primary px-4 text-sm font-medium text-primary-foreground hover:bg-primary/90">
            Get started
          </a>
        </DepthCardItem>
      </div>
    </DepthCard>
  )
}

API reference

PropTypeDefaultDescription
maxnumber12DepthCard: largest tilt in degrees.
perspectivenumber1000DepthCard: distance to the viewer in px. Smaller values exaggerate the depth.
containerClassNamestring—DepthCard: class for the outer element that holds the perspective.
depthnumber0DepthCardItem: how far the layer rises toward the viewer while the card is active, in px.
x, ynumber0DepthCardItem: sideways and vertical shift while active, in px.
rotateX, rotateY, rotateZnumber0DepthCardItem: extra rotation while active, in degrees.

Both accept all <div> props. DepthCard's className styles the card itself (border, background, padding).

Requirements

  • React 19 and Tailwind CSS v4.

Customization

  • Give the layers you want to stand out the biggest depth: 80–120px for a photo, 20–60px for text and buttons.
  • Style anything else on hover with group-data-active/depth-card:, e.g. a deeper shadow on the photo as in the demo.
  • Put several items in a row inside a div with transform-3d, so each keeps its own depth.

Accessibility

  • The motion is decoration only: content, links and buttons work the same flat.
  • Keyboard focus inside the card lifts the layers too, without tilting.
  • Touch users and anyone who prefers reduced motion see a flat card.

Troubleshooting

The layers don’t rise, or look flat.
Every element between a DepthCardItem and the card must keep 3D: add transform-3d, and remove overflow-hidden (clipping flattens 3D). Round images on the image itself instead.
Text looks blurry while the card is tilted.
Browsers rasterize 3D layers; keep max small (8–12) and depths under ~120px for crisp text.
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

A payment card with a holographic foil that follows the pointer, and a flip to the back on click.

Loading preview

A card that tilts in 3D toward the pointer, with a glare that follows it.

Loading preview

Cards arranged in a ring that turns in 3D, with buttons, arrow keys and announcements.