UniqueUI

Flip Card

3D card flip with spring physics, supporting hover or click triggers.

npx uniqueui add flip-card

Preview

Hover to flip →

Back side! ✨

Click to flip

Click again!

Usage

import { FlipCard } from "@/components/ui/flip-card";

export default function Example() {
  return (
    <div className="flex flex-wrap gap-8 items-center justify-center p-10 text-white">
      <FlipCard
        className="w-60 h-40"
        front={
          <div className="flex items-center justify-center h-full bg-zinc-900 rounded-xl border border-zinc-800">
            <p className="text-lg font-bold">Hover to flip →</p>
          </div>
        }
        back={
          <div className="flex items-center justify-center h-full bg-gradient-to-br from-purple-900 to-indigo-900 rounded-xl">
            <p className="text-lg font-bold text-purple-200">Back side! ✨</p>
          </div>
        }
      />
      <FlipCard
        className="w-60 h-40"
        trigger="click"
        front={
          <div className="flex items-center justify-center h-full bg-zinc-900 rounded-xl border border-zinc-800">
            <p className="text-lg font-bold">Click to flip</p>
          </div>
        }
        back={
          <div className="flex items-center justify-center h-full bg-zinc-800 rounded-xl border border-zinc-700">
            <p className="text-lg font-bold text-green-400">Click again!</p>
          </div>
        }
      />
    </div>
  );
}

Props

PropTypeDescription
frontReact.ReactNodeThe leading visible standard interface node.
backReact.ReactNodeThe trailing hidden secondary information node.
classNamestringOverarching classes driving constraints on the 3D rotating canvas.
frontClassNamestringGranular overrides for the un-rotated visual state.
backClassNamestringGranular overrides targeting the inverted 180-degree state representation.
trigger"hover" | "click"Enum literal targeting 'hover' execution or explicit 'click' toggles.
direction"horizontal" | "vertical"Axis orientation literal mapping rotation logic to 'horizontal' vs 'vertical'.
perspectivenumberZ-depth translation simulating three-dimensional depth stretching.