Skip to main content

React animation example

React Flip Card: 3D Card Flip Animation

A flip card shows two sides of one idea: a plan and its price, a question and its answer. This card rotates on a spring, so it overshoots slightly and settles like a physical card, and a highlight slides across the face as it turns. Hovering tilts it toward the cursor before you click.

  • 4.4 KB file
  • 6 live inputs
  • React runtime
Live, try it

How this 3d flip card works

  • Rotation is a spring from 0 to 180 degrees; the card is drawn with a horizontal scale of cos(angle) for the perspective.
  • Past 90 degrees the back face is drawn instead of the front, so text is never mirrored.
  • The flipped state is an input, so a parent component can flip a whole row of cards at once.

Add it to your React app

Install exodeui, download the file below, and paste this. The code updates as you customize. Other runtimes are in the other tabs.

import { ExodeUICanvas } from 'exodeui';

// react-flip-card.bexode goes in /public (download it below)
export function ReactFlipCard() {
  return (
    <ExodeUICanvas
      src="/react-flip-card.bexode"
      fit="Layout"
      autoPlay
      interactive
      onTrigger={(name) => {
        // fires: 'flip'
      }}
      style={{ width: '100%', height: 460 }}
    />
  );
}

Inputs

InputTypeDefaultRange
flippedBooleanfalse—
frontTextPro plan—
backText$29 / month—
accentText#8b5cf6hex colour
accent2Text#ec4899hex colour
bgText#0b0a12hex colour

Events: flip

More React animations

The same idea in other frameworks: Flutter credit card flip · SwiftUI flashcard deck