cnippet/ui
  1. motion
  2. text animations
  3. letter 3d swap

text animations

Letter 3D Swap

Each letter rotates in 3D space on hover — the front face spins away and a second face takes its place. Supports four rotation axes and independent colour per face.

Installation

Usage

Anatomy

Good to know

  • The effect plays on hover, so there's nothing to see on touch screens.
  • children should be plain text. It's split into letters.
  • Style the two faces separately with frontFaceClassName and secondFaceClassName.
  • rotateDirection is "top", "bottom", "left" or "right".
  • Screen readers read the full text once; the letter cubes are hidden from them.
  • When the user has turned on reduced motion, hovering does nothing and the text stays still.

Props

Examples

Nav links rotate upward on hover (rotateDirection="top"). Front face uses text-muted-foreground, second face reveals text-foreground — a colour-change through 3D space.

CTA Buttons

Two buttons — filled and outlined — with opposite rotateDirection values and staggerFrom="last" on the secondary to reverse the wave.

Direction Showcase

Four rows of the same word, each with a different rotateDirection. Hover to compare top, right, bottom, and left rotations side by side.