Daniel Petho

Letter 3D Swap

Text 2

About

A text component that rotates each letter in 3D on hover to reveal a second face, useful for animated headings and hero titles.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Letter 3D Swap to your project and fits it to your theme.

Code

How Letter 3D Swap is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import Letter3DSwap from "@/components/ui/letter-3d-swap";
import { useState } from "react";

export default function Preview() {
  const [debug, setDebug] = useState(false);
  const sharedProps = {
    mainClassName:
      "text-lg sm:text-3xl md:text-4xl bg-background lowercase text-foreground",
    frontFaceClassName: `bg-background ${debug ? "border" : ""}`,
    secondFaceClassName: `bg-background ${debug ? "border" : ""}`,
    staggerDuration: 0.02,
    transition: {
      type: "spring" as const,
      damping: 25,
      stiffness: debug ? 50 : 160,
    },
  };

  return (
    <div className="relative w-dvw h-dvh flex flex-col items-center justify-center p-4 sm:p-6 md:p-8 bg-background gap-4 sm:gap-6 md:gap-8">
      <div className="flex flex-col items-center gap-4 sm:gap-6 md:gap-8 max-w-xs sm:max-w-xl md:max-w-2xl font-cotham">
        <Letter3DSwap
          rotateDirection="left"
          staggerFrom="first"
          {...sharedProps}
        >
          Rotate Left, Stagger First
        </Letter3DSwap>

        <Letter3DSwap
          rotateDirection="right"
          staggerFrom="last"
          {...sharedProps}
        >
          Rotate Right, Stagger Last
        </Letter3DSwap>

        <Letter3DSwap
          rotateDirection="top"
          staggerFrom="center"
          {...sharedProps}
        >
          Rotate Top, Stagger Center
        </Letter3DSwap>

        <Letter3DSwap
          rotateDirection="bottom"
          staggerFrom="random"
          {...sharedProps}
        >
          Rotate Bottom, Stagger Random
        </Letter3DSwap>
      </div>
    </div>
  );
}

Dependencies

More by Daniel Petho

View all
  • Parallax Floating

    Parallax Floating

    2.2K
  • Text Rotate

    Text Rotate

    2.1K
  • Typewriter

    Typewriter

    1.9K
  • Marquee Along SVG Path

    Marquee Along SVG Path

    1.4K
  • Image Trail

    Image Trail

    1.4K
  • Animated Gradient With SVG

    Animated Gradient With SVG

    884
  • Text Cursor Proximity

    Text Cursor Proximity

    780
  • Pixel Trail

    Pixel Trail

    645

More in Text

View all
  • Vertical Cut Reveal Characters

    Vertical Cut Reveal Characters

    103
  • Rainbow Text Effect

    Rainbow Text Effect

    47
  • Text Loop

    Text Loop

    306
  • Motion Blur Text

    Motion Blur Text

    36
  • Text Reveal

    Text Reveal

    26
  • Apple Hello Effect

    Apple Hello Effect

    608
  • Lightning Text

    Lightning Text

    122
  • ParticleTextEffect

    ParticleTextEffect

    2.1K