Join our Discord Community
Interactive

3D Card

Interactive 3D perspective card with smooth hover transforms. Perfect for React applications requiring immersive UI elements with Next.js integration and TypeScript support.

Loading component...

Installation

npx shadcn@latest add https://www.shadcn.io/registry/3d-card.json
npx shadcn@latest add https://www.shadcn.io/registry/3d-card.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/3d-card.json
bunx shadcn@latest add https://www.shadcn.io/registry/3d-card.json

Features

  • Mouse-responsive transforms with real-time perspective calculations based on cursor position
  • Smooth hover animations using CSS 3D transforms and transition effects
  • Flexible content positioning with customizable translateX, translateY, translateZ values
  • Individual item control with independent rotation and translation properties
  • TypeScript support with comprehensive type definitions and props interface
  • Responsive design compatible with shadcn/ui design system and Tailwind CSS

Examples

Interactive Variant

Loading component...

Enhanced version showcasing additional transform properties and rotation effects.

Use Cases

This free open source React component works well for:

  • Product showcases - Interactive cards displaying features built with Next.js
  • Portfolio items - Creative presentations using TypeScript and Tailwind CSS
  • Hero sections - Engaging landing page elements with 3D effects
  • Dashboard widgets - Interactive data cards for modern applications

API Reference

CardContainer

PropTypeDefaultDescription
childrenReact.ReactNodeundefinedCard content elements
classNamestringundefinedCSS classes for the card container
containerClassNamestringundefinedCSS classes for the outer wrapper

CardBody

PropTypeDefaultDescription
childrenReact.ReactNoderequiredContent to be rendered inside the card body
classNamestringundefinedCSS classes for styling the card body

CardItem

PropTypeDefaultDescription
asReact.ElementType"div"HTML element type to render
childrenReact.ReactNoderequiredContent to be rendered inside the item
classNamestringundefinedCSS classes for styling
translateXnumber | string0X-axis translation in pixels
translateYnumber | string0Y-axis translation in pixels
translateZnumber | string0Z-axis translation in pixels
rotateXnumber | string0X-axis rotation in degrees
rotateYnumber | string0Y-axis rotation in degrees
rotateZnumber | string0Z-axis rotation in degrees

Implementation Notes

  • Wrap content within CardContainer for proper 3D perspective context
  • Use CardBody as the main content wrapper with preserve-3d transform style
  • Individual CardItem components respond to hover state automatically
  • Transform values accept both numbers (pixels/degrees) and string values
  • Compatible with all shadcn/ui components and design tokens
  • Requires no additional CSS setup beyond Tailwind CSS classes