Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | — | — |
| case-03 | ✗→✓ | ▲ Improved | — | — |
| case-17 | ✗→✓ | ▲ Improved | — | — |
| case-06 | ✗→✓ | ▲ Improved | — | — |
| case-04 | ✗→✓ | ▲ Improved | — | — |
Production-ready UI motion system for React / Next.js.
Focused on performance, accessibility, and usability — not decoration.
Use this motion system when motion:
Motion must:
If it does none → remove it.
bashnpm install motion
motion/react - default for current Motion for React projects (package: motion)framer-motion - legacy import path for projects that still depend on Framer MotionDo not mix. Mixing causes conflicting internal schedulers and broken AnimatePresence contexts — components from one package will not coordinate exit animations with components from the other.
To check which version your project uses:
bashcat package.json | grep -E '"motion"|"framer-motion"'
Always import from one source consistently:
ts// Correct (modern) import { motion, AnimatePresence } from "motion/react" // Correct (legacy) import { motion, AnimatePresence } from "framer-motion" // Never mix both in the same project
ts// motionTokens.ts export const motionTokens = { duration: { fast: 0.18, normal: 0.35, slow: 0.6 }, // Use these as the `ease` value inside a `transition` object: // transition={{ duration: motionTokens.duration.normal, ease: motionTokens.easing.smooth }} easing: { smooth: [0.22, 1, 0.36, 1] as [number, number, number, number], sharp: [0.4, 0, 0.2, 1] as [number, number, number, number] }, distance: { sm: 8, md: 16, lg: 24 } }
Usage example:
tsximport { motionTokens } from "@/lib/motionTokens" <motion.div initial={{ opacity: 0, y: motionTokens.distance.md }} animate={{ opacity: 1, y: 0 }} transition={{ duration: motionTokens.duration.normal, ease: motionTokens.easing.smooth }} />
Safe
Avoid
Rule: responsiveness > smoothness
The heuristic combines CPU core count and available memory for a more reliable signal. deviceMemory is available on Chrome/Android; the fallback covers Safari and Firefox.
tsconst isLowEnd = typeof navigator !== "undefined" && ( // Low memory (Chrome/Android only; undefined elsewhere → treat as capable) (navigator.deviceMemory !== undefined && navigator.deviceMemory <= 2) || // Few cores AND no memory API (covers Safari/Firefox on weak hardware) (navigator.deviceMemory === undefined && navigator.hardwareConcurrency <= 4) ) const duration = isLowEnd ? 0.2 : 0.4
tsximport { motion, useReducedMotion } from "motion/react" export function FadeIn() { const reduce = useReducedMotion() return ( <motion.div initial={{ opacity: 0, y: reduce ? 0 : 24 }} animate={{ opacity: 1, y: 0 }} /> ) }
css@media (prefers-reduced-motion: reduce) { .motion-safe-transition { transition: opacity 0.2s; } .motion-reduce-transform { transform: none !important; } }
html<div class="motion-safe:animate-fade motion-reduce:opacity-100"></div>
| Scenario | Pattern | |---|---| | Hover feedback | whileHover | | Tap / press feedback | whileTap | | Reveal on scroll | whileInView | | Scroll-linked value | useScroll + useTransform | | Conditional mount/unmount | AnimatePresence | | Small layout shifts (single element, < ~300px change) | layout prop | | Large layout shifts or full-page reflows | Avoid layout; use CSS transitions or page-level routing instead | | Complex, imperative sequences | useAnimate |
> Why avoid layout on large containers? Framer's layout animation uses transform to reconcile positions, but on elements that span the full viewport or trigger deep reflow, the measurement cost causes visible jank and CLS. Prefer CSS Grid/Flexbox transitions or coordinate with layoutId on specific child elements only.
layoutId (must be unique per mounted instance)AnimatePresence (see mode guidance below)modeAlways specify mode explicitly — the default ("sync") runs enter and exit simultaneously, which causes visual overlap in most UI patterns.
| mode | When to use | |---|---| | "wait" | Exit completes before enter starts. Use for modals, toasts, page transitions. | | "sync" (default) | Enter and exit overlap. Use only when overlap is intentional (e.g., crossfade carousels). | | "popLayout" | Exiting element is popped out of flow immediately; remaining items animate to fill. Use for lists, tabs, dismissible cards. |
tsx// Modal — always use "wait" <AnimatePresence mode="wait"> {open && <Modal key="modal" />} </AnimatePresence> // Dismissible list item — use "popLayout" <AnimatePresence mode="popLayout"> {items.map(item => <Card key={item.id} />)} </AnimatePresence>
layoutId)AnimatePresence mode="wait" so exit animation completes before the next modal enterstsximport React, { useEffect, useRef, useState } from "react" import { motion, AnimatePresence } from "motion/react" function useFocusTrap(ref: React.RefObject<HTMLDivElement | null>, active: boolean) { useEffect(() => { if (!active || !ref.current) return const el = ref.current const focusable = el.querySelectorAll<HTMLElement>( 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])' ) const first = focusable[0] const last = focusable[focusable.length - 1] function handleKey(e: KeyboardEvent) { if (e.key !== "Tab") return if (e.shiftKey && document.activeElement === first) { e.preventDefault() last?.focus() } else if (!e.shiftKey && document.activeElement === last) { e.preventDefault() first?.focus() } } el.addEventListener("keydown", handleKey) first?.focus() return () => el.removeEventListener("keydown", handleKey) }, [active, ref]) } function useScrollLock(active: boolean) { useEffect(() => { if (!active) return const prev = document.body.style.overflow document.body.style.overflow = "hidden" return () => { document.body.style.overflow = prev } }, [active]) } function Modal({ open, closeModal }: { open: boolean; closeModal: () => void }) { const ref = useRef<HTMLDivElement>(null) useFocusTrap(ref, open) useScrollLock(open) useEffect(() => { function onKey(e: KeyboardEvent) { if (e.key === "Escape") closeModal() } if (open) window.addEventListener("keydown", onKey) return () => window.removeEventListener("keydown", onKey) }, [open, closeModal]) return ( // mode="wait" ensures exit animation finishes before any new modal enters <AnimatePresence mode="wait"> {open && ( <motion.div role="dialog" aria-modal="true" aria-labelledby="modal-title" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: 0.2 }} className="fixed inset-0 flex items-center justify-center bg-black/40" > <motion.div ref={ref} initial={{ scale: 0.95, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} exit={{ scale: 0.95, opacity: 0 }} transition={{ duration: 0.2, ease: [0.22, 1, 0.36, 1] }} className="bg-white p-6 rounded" > <h2 id="modal-title">Dialog Title</h2> <button onClick={closeModal}>Close</button> </motion.div> </motion.div> )} </AnimatePresence> ) } export function Example() { const [open, setOpen] = useState(false) return ( <> <button onClick={() => setOpen(true)}>Open</button> <Modal open={open} closeModal={() => setOpen(false)} /> </> ) }
initial explicitly)"use client" in Next.js App RouterCheck:
motion/react and framer-motion)"use client" directive in Next.js App Routerkey prop on AnimatePresence childrenlayout prop misuse on large containers causing reflow jankrole="dialog", aria-modal="true")useReducedMotion + CSS media query)AnimatePresence mode set explicitly on all usage siteswidth, height, top, left)staggerChildren ≤ 0.1s; beyond that it feels slow)layout on large or full-viewport containersmode on AnimatePresence (default "sync" causes visual overlap)Motion is interaction design.
> If motion does not improve UX → remove it.
tsximport { motion } from "motion/react" export function Button() { return ( <motion.button whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.97 }} transition={{ duration: 0.15, ease: [0.4, 0, 0.2, 1] }} > Click me </motion.button> ) }
tsximport { motion, useReducedMotion } from "motion/react" export function FadeIn() { const reduce = useReducedMotion() return ( <motion.div initial={{ opacity: 0, y: reduce ? 0 : 24 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: reduce ? 0.1 : 0.35, ease: [0.22, 1, 0.36, 1] }} /> ) }
tsximport { motion } from "motion/react" const container = { hidden: {}, visible: { transition: { staggerChildren: 0.08 } // keep ≤ 0.1s to avoid sluggishness } } const item = { hidden: { opacity: 0, y: 10 }, visible: { opacity: 1, y: 0, transition: { duration: 0.3, ease: [0.22, 1, 0.36, 1] } } } export function List() { return ( <motion.ul variants={container} initial="hidden" animate="visible"> {[1, 2, 3].map(i => ( <motion.li key={i} variants={item}>Item {i}</motion.li> ))} </motion.ul> ) }
tsximport { motion, AnimatePresence } from "motion/react" export function Modal({ open }: { open: boolean }) { return ( <AnimatePresence mode="wait"> {open && ( <motion.div initial={{ opacity: 0, scale: 0.95 }} animate={{ opacity: 1, scale: 1 }} exit={{ opacity: 0, scale: 0.95 }} transition={{ duration: 0.2, ease: [0.22, 1, 0.36, 1] }} /> )} </AnimatePresence> ) }
tsximport { useScroll, useTransform, motion } from "motion/react" export function Parallax() { const { scrollYProgress } = useScroll() const y = useTransform(scrollYProgress, [0, 1], [0, -80]) return <motion.div style={{ y }} /> }
tsximport { motion } from "motion/react" export function Skeleton() { return ( <motion.div className="bg-gray-200 h-6 w-full rounded" animate={{ opacity: [0.5, 1, 0.5] }} transition={{ duration: 1.5, // comfortable pulse — was missing, caused fast flash repeat: Infinity, ease: "easeInOut" }} /> ) }
tsximport { motion } from "motion/react" // layoutId must be unique per mounted instance. // If multiple instances can exist simultaneously, append a unique id: // layoutId={`shared-${item.id}`} export function Shared() { return <motion.div layoutId="shared" /> }
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +45 percentage points is the difference between those two pass rates over the 22 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.