Join our Discord Community

React Flip Button

React flip button with 3D animations that reveal hidden messages on hover. Smooth transitions and customizable directions with TypeScript and shadcn/ui.

Creating interactive button animations?

Join our Discord community for help from other developers.


Remember those business cards that flip to reveal contact details? That satisfying rotation that makes you want to hover again? Most button hover effects are boring—color changes, slight scales, maybe a shadow. This React component gives you smooth 3D flips that reveal entirely different content, making every interaction feel premium.

3D flip on hover

Hover to reveal hidden messages with buttery smooth perspective transforms:

Loading component...

Built for React applications with TypeScript and Next.js. Uses Framer Motion for physics-based spring animations that feel natural, not mechanical. The 3D perspective runs on the GPU, keeping your JavaScript thread free. Works seamlessly with shadcn/ui design systems.

Installation

npx shadcn@latest add https://www.shadcn.io/registry/flip-button.json
npx shadcn@latest add https://www.shadcn.io/registry/flip-button.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/flip-button.json
bunx shadcn@latest add https://www.shadcn.io/registry/flip-button.json

Usage

import { FlipButton } from "@/components/ui/flip-button";

export default function CTASection() {
  return (
    <div className="flex gap-4">
      <FlipButton
        frontText="Get Started"
        backText="Let's Go! 🚀"
        from="top"
      />
      <FlipButton
        frontText="Learn More"
        backText="Discover →"
        from="left"
        frontClassName="bg-secondary"
        backClassName="bg-primary"
      />
    </div>
  );
}

Why most hover effects suck

Developers love their hover:scale-105 and call it interactive. Or they add a color change that's barely noticeable. The problem? Users are numb to these micro-interactions. They don't create delight or engagement anymore.

3D flips are different. They reveal information, create anticipation, and feel intentional. This React component handles the complex parts: perspective math, backface visibility, state management, and spring physics. You just provide the text and it handles the rest.

Plus, it's not just about the flip—it's about the physics. The spring animation feels natural because it uses real physics calculations, not linear transitions that feel robotic.

Examples

Flip Directions

Four directions for different visual personalities—each creates unique spatial movement:

Loading component...

Features

  • Smooth 3D flip animations with real physics-based spring transitions that feel natural
  • Four flip directions (top, bottom, left, right) for different interaction patterns
  • Customizable face styling with separate classes for front and back appearances
  • GPU-accelerated transforms using CSS 3D perspective for buttery smooth 60fps
  • TypeScript definitions with complete prop types and direction enums
  • Automatic dimension preservation maintaining consistent button size during flips
  • Framer Motion springs providing natural acceleration and deceleration curves
  • Accessible hover states with proper focus management and keyboard support

API Reference

FlipButton

The main component for 3D flip button interactions with customizable content.

PropTypeDefaultDescription
frontTextstringrequiredText displayed on the front face
backTextstringrequiredText revealed on the back face during hover
from"top" | "bottom" | "left" | "right""top"Direction of the flip animation
transitionTransition{ type: "spring", stiffness: 280, damping: 20 }Framer Motion transition configuration
frontClassNamestring-CSS classes for front face styling
backClassNamestring-CSS classes for back face styling
classNamestring-CSS classes for the button container
...propsHTMLMotionProps-All Framer Motion button props supported

Direction Behaviors

Each direction creates distinct spatial movement:

DirectionAxisVisual EffectUse Case
topX-axisFlips upward like a cardRevealing upgrades, positive actions
bottomX-axisFlips downwardShowing details, expanding information
leftY-axisRotates left like a doorNavigation, going back
rightY-axisRotates rightForward progress, next steps

Spring Physics

The default spring configuration provides natural movement:

// Snappy, responsive feel (default)
transition={{ type: "spring", stiffness: 280, damping: 20 }}

// Smooth, elegant motion
transition={{ type: "spring", stiffness: 200, damping: 25 }}

// Bouncy, playful interaction
transition={{ type: "spring", stiffness: 400, damping: 15 }}

// Quick, minimal movement
transition={{ type: "spring", stiffness: 500, damping: 30 }}

Common gotchas

Text length mismatches: If your front and back text have very different lengths, the button might resize during flip. The component handles this with an invisible text layer, but extreme differences can still cause layout shift.

Mobile hover behavior: On touch devices, the flip triggers on tap and stays flipped until another tap. This is standard mobile behavior but might surprise users expecting desktop-like hover.

Perspective container issues: The 3D perspective requires a container with defined dimensions. If your button appears flat, check that parent elements have proper height/width.

Z-index stacking: During flip, the button temporarily extends in 3D space. Elements with high z-index nearby might clip the animation. Give the button container adequate spacing.

Custom spring values: Very low damping (less than 10) creates excessive bounce that looks unnatural. Very high stiffness (greater than 600) makes the animation too quick to perceive.

You might also like

Explore other interactive button components for React applications:

Questions developers actually ask