THE PLAYGROUND · CORE MOTION
Morphing
A shape smoothly transforms into another shape.
MorphingCore Motion · A shape smoothly transforms into another shape.
CLICK1import { useState } from "react";2import { motion } from "motion/react";3 4const surface = { width: 100, height: 100, borderRadius: 16, background: "#b8ed79", display: "grid", placeItems: "center", color: "#141714" };5 6export default function MorphDemo() {7 const [run, setRun] = useState(0);8 return <div>9 <button onClick={() => setRun(v => v + 1)}>Replay</button>10 <motion.div key={run} style={surface} animate={{11 "borderRadius": [12 "24%",13 "50%",14 "10%",15 "24%"16 ],17 "width": [18 88,19 104,20 140,21 8822 ]23}} transition={{ duration: 0.6, delay: 0, ease: "easeInOut" }}>Motion</motion.div>24 </div>;25}Install: npm install motion. Animate border radius and size together.