<div id="root"></div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
line-height: 1.5;
font-size: 15px;
font-weight: 400;
}
body {
width: 100vw;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
gap: 20px;
font-family: "Exo", Arial, sans-serif;
background-color: #151522;
color: #fff;
}
#root {
display: flex;
justify-content: center;
align-items: center;
}
.box {
min-width: 30vh;
aspect-ratio: 1/1;
background-color: #f36;
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
border-radius: 8px;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
padding: 10px;
font-size: 1.2rem;
}
const { motion } = Motion;
const variant = {
active: {
rotate: 90,
scale: 1.5,
opacity: 1
},
inactive: {
rotate: 0,
scale: 1,
opacity: 0.75
}
};
const App = () => {
const [isActive, setIsActive] = React.useState(false);
return (
<motion.div
className="box"
onClick={() => setIsActive(!isActive)}
variants={variant}
animate={isActive ? "active" : "inactive"}
>
Click Me (^_^) !{" "}
</motion.div>
);
};
ReactDOM.render(<App />, document.getElementById("root"));
View Compiled
This Pen doesn't use any external CSS resources.