THE PLAYGROUND · CORE MOTION
Shake / Wiggle
A quick side-to-side movement signals a change.
Shake / WiggleCore Motion · A quick side-to-side movement signals a change.
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 ShakeDemo() {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 "x": [12 0,13 -16,14 16,15 -12,16 12,17 018 ],19 "rotate": [20 0,21 -5,22 5,23 -3,24 3,25 026 ]27}} transition={{ duration: 0.6, delay: 0, ease: "easeInOut" }}>Motion</motion.div>28 </div>;29}Install: npm install motion. Keep shakes brief and provide a text error too.