JSFiddle - React, Tailwind, and code Playground

HTML

<button id="flip">Flip Card</button>
<section class="container">
    <div id="card">
        <figure class="front">1</figure>
        <figure class="back">2</figure>
    </div>
</section>

CSS

.container {
    position: relative;
    -webkit-perspective: 800px;
}
#card {
    width: 200px;
    height: 300px;
    position: absolute;
    -webkit-transform-style: preserve-3d;
}
#card figure {
    display: block;
    height: 100%;
    width: 100%;
    line-height: 260px;
    color: white;
    text-align: center;
    font-weight: bold;
    font-size: 140px;
    position: absolute;
    -webkit-backface-visibility: hidden;
}
#card .front {
    transition: all 1s;
    background: red;
    -webkit-transform: rotateY(0deg)  rotateZ(200deg);
}
#card .back {
    transition: all 1s;
    background: blue;
    -webkit-transform: rotateY(180deg)  rotateZ(200deg);
}

#card.flipped .front {
    -webkit-transform: rotateY(180deg)  rotateZ(0deg);
}
#card.flipped .back {
    -webkit-transform: rotateY(0deg)  rotateZ(0deg);
}

JavaScript

var card = document.getElementById("card");
document.getElementById("flip").addEventListener("click", function() {
    card.classList.toggle("flipped");
});