Flip Badge
Ever wanted a badge that stands out—literally? This component adds a dynamic flipping effect to your badges, making them feel interactive and eye-catching. Perfect for status indicators, achievement badges, or call-to-action elements. Fully customizable with different colors, and content on each side.
Preview
"Should be an
easy fix"
*Spends
6 hours*
Follow below steps 👇🏻
Install dependencies
1npm i framer-motion
Styles
Add these styles in your .css file
1@keyframes flip {20% {3transform: rotateY(0deg);4}550% {6transform: rotateY(-180deg);7}8100% {9transform: rotateY(-360deg);10}11}1213/* Apply animation to the entire container */14.flip {15animation: flip 2.4s linear infinite;16transform-style: preserve-3d;17position: relative;18}1920/* Ensure back side is rotated initially */21.flip-back {22transform: rotateY(180deg);23}
Component
Create a file flip-badge.tsx in your components folder and paste this code
1import React from 'react';2import { motion } from 'framer-motion';34const FlipBadge = ({5frontContent,6backContent7}: {8// * Remove these data types for javascript9frontContent?: string | React.ReactNode;10backContent?: string | React.ReactNode;11// * ----12}) => {13return (14<motion.div15initial={{ y: -5 }}16animate={{17y: 0,18transition: { repeat: Infinity, duration: 0.8, repeatType: 'reverse' }19}}20className="relative h-[200px] w-[200px] rounded-full"21style={{ perspective: '1000px' }}22>23<div className="flip h-full w-full rounded-full relative flex items-center justify-center">24<motion.div25animate={{26boxShadow: [27'0 -10px 10px rgba(255, 85, 0, 0.5), 0 -10px 20px rgba(255, 100, 0, 0.6), 0 -10px 30px rgba(255, 120, 0, 0.7)',28'0 -10px 15px rgba(255, 100, 0, 0.6), 0 -10px 25px rgba(255, 120, 0, 0.7), 0 -10px 35px rgba(255, 150, 0, 0.8)',29'0 -10px 12px rgba(255, 85, 0, 0.5), 0 -10px 22px rgba(255, 100, 0, 0.6), 0 -10px 32px rgba(255, 120, 0, 0.7)'30]31}}32transition={{ duration: 1.5, repeat: Infinity, ease: 'easeInOut' }}33className="absolute inset-0 rounded-full border border-orange-500"34></motion.div>3536{/* Front Side */}37<div38className="h-full w-full absolute top-0 left-0 flex items-center justify-center rounded-full"39style={{40backfaceVisibility: 'hidden',41background: 'radial-gradient(circle at center, #ffebe6da, #adadadaa)'42}}43>44{frontContent}45</div>4647{/* Back Side*/}48<div49className="h-full w-full absolute top-0 left-0 flex items-center justify-center bg-neutral-700 rounded-full flip-back"50style={{51backfaceVisibility: 'hidden',52background: 'radial-gradient(circle at center, #2e2a2900, #ododod)'53}}54>55{backContent}56</div>57</div>58</motion.div>59);60};6162export default FlipBadge;
💡 Customize the background colors to anything you like—make it as wild or as classy as you want!
Usage
1<FlipBadge2frontContent={<p className="font-medium text-black">"Should be an easy fix"</p>}3backContent={<p className="font-medium text-white">*Spends 6 hours*</p>}4/>
⭐️ Got a question or feedback?
Feel free to reach out!