JSFiddle - React, Tailwind, and code Playground

by labsisouleimen

HTML

<script src="https://cdn.jsdelivr.net/gh/labsisouleimen/[email protected]/TouchFlip3D.js"></script>

<div class="main-container">
    <h2 class="title">TouchFlip3D Demo</h2>
    
    <div class="card-holder">
        <touch-flip-3d>
            <div slot="front" class="card front">
                <div class="card-header">
                    <div class="chip"></div>
                    <span class="provider">PREMIUM</span>
                </div>
                <div class="card-number">5588 9911 2233 4455</div>
                <div class="card-footer">
                    <div class="label-group">
                        <small>CARD HOLDER</small>
                        <p>LABSI SOULEIMEN</p>
                    </div>
                    <div class="label-group">
                        <small>EXPIRES</small>
                        <p>12/28</p>
                    </div>
                </div>
            </div>

            <div slot="back" class="card back">
                <div class="magnetic-strip"></div>
                <div class="cvv-section">
                    <div class="signature-bar"></div>
                    <div class="cvv-code">123</div>
                </div>
                <div class="back-text">
                    <p>This card is powered by TouchFlip3D Web Library.</p>
                    <p>Authorized Signature - Not Valid Unless Signed</p>
                </div>
            </div>
        </touch-flip-3d>
    </div>
    
    <p class="instruction">Drag or touch to flip the card</p>
</div>

CSS

body {
    background: #eef2f3;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
}

.main-container {
    text-align: center;
}

.title {
    color: #2c3e50;
    margin-bottom: 30px;
    font-weight: 300;
    letter-spacing: 2px;
}

.card-holder {
    width: 380px;
    height: 240px;
    margin: 0 auto;
}

.card {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    padding: 25px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

/* Front Side Style */
.front {
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    color: white;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chip {
    width: 50px;
    height: 40px;
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    border-radius: 8px;
}

.provider {
    font-weight: bold;
    font-style: italic;
    opacity: 0.8;
}

.card-number {
    font-size: 22px;
    letter-spacing: 3px;
    word-spacing: 5px;
    margin: 20px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    text-align: left;
}

.label-group small {
    font-size: 10px;
    opacity: 0.7;
    display: block;
}

.label-group p {
    margin: 5px 0 0;
    font-size: 14px;
    letter-spacing: 1px;
}

/* Back Side Style */
.back {
    background: #2d3436;
    color: white;
    padding: 0; /* Stripe needs to be edge-to-edge */
}

.magnetic-strip {
    width: 100%;
    height: 50px;
    background: #000;
    margin-top: 30px;
}

.cvv-section {
    padding: 20px;
    display: flex;
    align-items: center;
    gap:...