3D flip
Also called card flip or flip card animation
A card that turns over in 3D to reveal a second face on its back, built with rotateY and backface-visibility: hidden.
import { useState } from 'react';
// Both faces share one grid cell and hide their back side.
const FACE =
'col-start-1 row-start-1 flex min-h-44 flex-col items-center justify-center gap-2 rounded-2xl border p-6 backface-hidden transition-opacity duration-300';
export function Flashcard() {
const [flipped, setFlipped] = useState(false);
return (
<button
type='button'
onClick={() => setFlipped(!flipped)}
className='w-72 rounded-2xl perspective-[1000px]'
>
{/* With reduced motion the card stays put and the faces crossfade. */}
<span
className={`grid transform-3d transition-transform duration-600 ease-in-out ${flipped ? 'motion-safe:rotate-y-180' : ''}`}
>
{/* inert keeps the hidden face out of the button's accessible name. */}
<span
inert={flipped}
className={`${FACE} bg-background ${flipped ? 'motion-reduce:opacity-0' : ''}`}
>
<span className='text-2xl font-semibold'>¿Cómo estás?</span>
<span className='text-sm text-muted-foreground'>Show answer</span>
</span>
<span
inert={!flipped}
className={`${FACE} bg-muted motion-safe:rotate-y-180 ${flipped ? '' : 'motion-reduce:opacity-0'}`}
>
<span className='text-2xl font-semibold'>How are you?</span>
<span className='text-sm text-muted-foreground'>Show question</span>
</span>
</span>
</button>
);
}Build a flashcard that flips when clicked or when Enter is pressed: stack both faces in one grid cell, pre-rotate the back with rotateY(180deg), set backface-visibility: hidden on both faces and transform-style: preserve-3d on the card, and put perspective: 1000px on its wrapper. Animate rotateY over 600ms with ease-in-out, make the hidden face inert, and crossfade instead of flipping when prefers-reduced-motion is set.
Paste into Layerwise or any AI coding tool.
What is 3D flip?
A flip card stacks two faces in the same spot and turns the back one around ahead of time with rotateY(180deg). Rotating the card 180deg brings the back into view. Three pieces make it work: transform-style: preserve-3d keeps the faces in 3D space, backface-visibility: hidden hides whichever face points away, and perspective on the parent makes the near edge grow as it turns.
Use it when the two sides really are the front and back of one thing: flashcards, playing cards, a product card that turns to show specs, or a payment form that flips the card preview to the CVC field.
Around 500 to 800ms with ease-in-out reads well. Hide the face that is turned away from screen readers with inert, let keyboard users flip with a real button, and crossfade the faces instead of flipping for people who prefer reduced motion.
Often confused with
- 3D tilt card
- A 3D tilt card leans a few degrees toward the pointer. A 3D flip turns the card all the way over to show its back.
Related terms
All termsPerspective
A CSS property that sets how far the viewer sits from a 3D scene, so rotated elements look deep up close and flatter from far away.
Rotate
A CSS transform that turns an element around its transform origin by an angle, such as `rotate(45deg)`.
3D tilt card
A card that tips in 3D as the mouse moves over it, often with a moving glare, so it feels like a physical object in your hand.
Crossfade
A transition where the old content fades out while the new content fades in at the same spot, so the two briefly overlap.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.