[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DB3CD419TBYQ22MVHN1WMS":3,"skill-same:01M7DB3CD419TBYQ22MVHN1WMS":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":31,"commitSha":32,"skillDirectory":33,"forksCount":34,"repositoryHtmlUrl":35,"repositoryHomepageUrl":6,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":37,"install":38,"resources":51},"01M7DB3CD419TBYQ22MVHN1WMS","motion-patterns",null,"Production-ready animation patterns for React \u002F Next.js — button, modal, toast, stagger, page transitions, exit animations, scroll, and layout — built on motion-foundations tokens and springs. Use when animating a specific UI element in React or Next.js — button, modal, toast, stagger, page transition, or scroll.","MoradDev\u002Fskills-unified","MoradDev","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F72839584?v=4","01M7DASN3HYHFBYW4ZNMPTHQ63","01M7DASN4N6P4P9WMEFRE2V0TF",2,"MIT","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fmotion-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: motion-patterns\ndescription: Production-ready animation patterns for React \u002F Next.js — button, modal, toast, stagger, page transitions, exit animations, scroll, and layout — built on motion-foundations tokens and springs. Use when animating a specific UI element in React or Next.js — button, modal, toast, stagger, page transition, or scroll.\ntags: [motion, animation, ui-patterns]\ncategory: frontend\nauthor: jeff\nmetadata:\n  version: 1.0.0\n---\n\n# Motion Patterns\n\nCopy-paste patterns for the most common UI animation needs.\nEvery pattern here is built on `motion-foundations` tokens and springs.\nDo not define new duration or easing values here — import them.\n\n## When to Activate\n\n- Animating a button, card, modal, or toast notification\n- Building list entrances with stagger\n- Setting up page transitions in Next.js App Router\n- Adding entrance or exit animations to conditional content\n- Implementing scroll-reveal, scroll-linked progress, or sticky story sections\n- Building expanding cards, accordions, or shared-element transitions\n\n## Outputs\n\nThis skill produces:\n\n- Accessible, SSR-safe animation for all standard UI components\n- `AnimatePresence`-wrapped conditional renders with correct exit behavior\n- Page transition wrapper component for Next.js App Router\n- Scroll-reveal and scroll-linked patterns using `useScroll` + `useTransform`\n- Layout animation patterns (`layout`, `layoutId`) for expanding and crossfading elements\n\n## Principles\n\n- Every pattern imports from `motion-foundations`. No raw numbers.\n- Every conditional render is wrapped in `AnimatePresence` with a `key`.\n- Exit animations are always defined alongside enter animations — never as an afterthought.\n- `layout` is used only for small, isolated shifts. Large subtrees get explicit transforms.\n\n## Rules\n\n1. **Always wrap conditional renders in `AnimatePresence` with a `key`** on the direct child. Without a key, exit animations never fire.\n2. **Always define `exit` when defining `initial` + `animate`.** An animation without an exit is incomplete.\n3. **Use `mode=\"wait\"` on page transitions.** Enter must not start until exit completes.\n4. **Never use `layout` on subtrees with more than ~5 children or deeply nested DOM.** Use explicit `x`\u002F`y` transforms instead.\n5. **Stagger interval must stay between `0.05s` and `0.10s`.** Below feels mechanical; above feels sluggish.\n6. **Modals must always include:** focus trap, Escape-key close, scroll lock, `role=\"dialog\"`, `aria-modal=\"true\"`.\n7. **Scroll reveals use `viewport={{ once: true }}`.** Repeating on scroll-out is distracting, not informative.\n8. **All token values are imported from `motion-foundations`.** No inline numbers.\n\n## Decision Guidance\n\n### Choosing the right pattern\n\n| Situation | Pattern |\n| ---------------------------------------- | ---------------------- |\n| Element appears \u002F disappears             | `AnimatePresence`      |\n| List of items loading in sequence        | Stagger variants       |\n| Navigating between routes                | Page transition wrapper|\n| Element changes size in place            | `layout` prop          |\n| Same element moves across page contexts  | `layoutId`             |\n| Element enters when scrolled into view   | `whileInView`          |\n| Value tied to scroll position            | `useScroll` + `useTransform` |\n\n### When to use `mode=\"wait\"` vs `mode=\"sync\"`\n\n| Mode | Use when |\n| ------- | --------------------------------------- |\n| `wait` | Page transitions, content swaps (one at a time) |\n| `sync` | Stacked notifications, list items (overlap is fine) |\n| `popLayout` | Items removed from a reflow list |\n\n## Core Concepts\n\n### AnimatePresence contract\n\nThree things must always be true:\n\n1. `AnimatePresence` wraps the conditional\n2. The direct child has a `key`\n3. The child has an `exit` prop\n\nMiss any one of these and the exit animation silently fails.\n\n### layout vs layoutId\n\n- `layout` — animates the element's own size\u002Fposition change in place\n- `layoutId` — links two separate elements, crossfading between them across renders\n\nUse `layout=\"position\"` on text inside an expanding container to prevent text reflow from animating.\n\n## Code Examples\n\n### Button feedback\n\n```tsx\n\"use client\"\nimport { motion } from \"motion\u002Freact\"\nimport { springs, motionTokens } from \"@\u002Flib\u002Fmotion-tokens\"\n\n\u003Cmotion.button\n  whileHover={{ scale: motionTokens.scale.pop }}\n  whileTap={{ scale: motionTokens.scale.press }}\n  transition={springs.snappy}\n\u002F>\n```\n\n### Stagger list\n\n```tsx\n\"use client\"\nimport { motion } from \"motion\u002Freact\"\nimport { motionTokens, springs } from \"@\u002Flib\u002Fmotion-tokens\"\n\nconst container = {\n  hidden: {},\n  visible: {\n    transition: {\n      staggerChildren: 0.08,   \u002F\u002F within the 0.05–0.10 rule\n      delayChildren: 0.1,\n    },\n  },\n}\n\nconst item = {\n  hidden:  { opacity: 0, y: motionTokens.distance.md },\n  visible: { opacity: 1, y: 0, transition: springs.gentle },\n}\n\n\u003Cmotion.ul variants={container} initial=\"hidden\" animate=\"visible\">\n  {items.map((i) => (\n    \u003Cmotion.li key={i.id} variants={item} \u002F>\n  ))}\n\u003C\u002Fmotion.ul>\n```\n\n### Modal\n\n```tsx\n\"use client\"\nimport { motion, AnimatePresence } from \"motion\u002Freact\"\nimport { motionTokens, springs } from \"@\u002Flib\u002Fmotion-tokens\"\n\n\u002F\u002F Wrap at the call site:\n\u002F\u002F \u003CAnimatePresence>{isOpen && \u003CModal key=\"modal\" \u002F>}\u003C\u002FAnimatePresence>\n\nexport function Modal({ onClose }: { onClose: () => void }) {\n  return (\n    \u003C>\n      {\u002F* Overlay *\u002F}\n      \u003Cmotion.div\n        className=\"fixed inset-0 bg-black\u002F50\"\n        initial={{ opacity: 0 }}\n        animate={{ opacity: 1 }}\n        exit={{ opacity: 0 }}\n        onClick={onClose}\n      \u002F>\n\n      {\u002F* Panel — accessibility requirements: focus trap, Escape close,\n          scroll lock, role=\"dialog\", aria-modal=\"true\" *\u002F}\n      \u003Cmotion.div\n        role=\"dialog\"\n        aria-modal=\"true\"\n        className=\"fixed inset-x-4 top-1\u002F2 -translate-y-1\u002F2 rounded-xl bg-white p-6\"\n        initial={{\n          opacity: 0,\n          scale: motionTokens.scale.press,\n          y: motionTokens.distance.sm,\n        }}\n        animate={{ opacity: 1, scale: 1, y: 0 }}\n        exit={{\n          opacity: 0,\n          scale: motionTokens.scale.press,\n          y: motionTokens.distance.sm,\n        }}\n        transition={springs.gentle}\n      \u002F>\n    \u003C\u002F>\n  )\n}\n```\n\n### Toast stack\n\n```tsx\n\"use client\"\nimport { motion, AnimatePresence } from \"motion\u002Freact\"\nimport { motionTokens, springs } from \"@\u002Flib\u002Fmotion-tokens\"\n\n\u003CAnimatePresence mode=\"sync\">\n  {toasts.map((t) => (\n    \u003Cmotion.div\n      key={t.id}\n      layout\n      initial={{\n        opacity: 0,\n        x: motionTokens.distance.xl,\n        scale: motionTokens.scale.subtle,\n      }}\n      animate={{ opacity: 1, x: 0, scale: 1 }}\n      exit={{\n        opacity: 0,\n        x: motionTokens.distance.xl,\n        scale: motionTokens.scale.subtle,\n      }}\n      transition={springs.snappy}\n    \u002F>\n  ))}\n\u003C\u002FAnimatePresence>\n```\n\n### Page transition (Next.js App Router)\n\n```tsx\n\u002F\u002F components\u002Fpage-transition.tsx\n\"use client\"\nimport { motion, AnimatePresence } from \"motion\u002Freact\"\nimport { usePathname } from \"next\u002Fnavigation\"\nimport { motionTokens } from \"@\u002Flib\u002Fmotion-tokens\"\n\nconst variants = {\n  initial: { opacity: 0, y: motionTokens.distance.sm },\n  enter:   { opacity: 1, y: 0 },\n  exit:    { opacity: 0, y: -motionTokens.distance.sm },\n}\n\nexport function PageTransition({ children }: { children: React.ReactNode }) {\n  const pathname = usePathname()\n  return (\n    \u003CAnimatePresence mode=\"wait\">\n      \u003Cmotion.div\n        key={pathname}\n        variants={variants}\n        initial=\"initial\"\n        animate=\"enter\"\n        exit=\"exit\"\n        transition={{\n          duration: motionTokens.duration.normal,\n          ease: motionTokens.easing.smooth,\n        }}\n      >\n        {children}\n      \u003C\u002Fmotion.div>\n    \u003C\u002FAnimatePresence>\n  )\n}\n```\n\n### Scroll reveal\n\n```tsx\n\"use client\"\nimport { motion } from \"motion\u002Freact\"\nimport { motionTokens, springs } from \"@\u002Flib\u002Fmotion-tokens\"\n\n\u003Cmotion.div\n  initial={{ opacity: 0, y: motionTokens.distance.lg }}\n  whileInView={{ opacity: 1, y: 0 }}\n  viewport={{ once: true, margin: \"-80px\" }}   \u002F\u002F once: true — rule 7\n  transition={{ duration: motionTokens.duration.slow, ease: motionTokens.easing.smooth }}\n\u002F>\n```\n\n### Scroll progress bar\n\n```tsx\n\"use client\"\nimport { motion, useScroll } from \"motion\u002Freact\"\n\nexport function ScrollProgress() {\n  const { scrollYProgress } = useScroll()\n  return (\n    \u003Cmotion.div\n      className=\"fixed top-0 left-0 h-1 bg-indigo-500 origin-left w-full\"\n      style={{ scaleX: scrollYProgress }}\n    \u002F>\n  )\n}\n```\n\n### Expanding card\n\n```tsx\n\"use client\"\nimport { useState } from \"react\"\nimport { motion, AnimatePresence } from \"motion\u002Freact\"\nimport { springs, motionTokens } from \"@\u002Flib\u002Fmotion-tokens\"\n\nexport function ExpandingCard({ title, body }: { title: string; body: string }) {\n  const [expanded, setExpanded] = useState(false)\n\n  return (\n    \u003Cmotion.div layout onClick={() => setExpanded(!expanded)} className=\"cursor-pointer\">\n      {\u002F* layout=\"position\" prevents text reflow from animating *\u002F}\n      \u003Cmotion.h2 layout=\"position\" className=\"font-semibold\">\n        {title}\n      \u003C\u002Fmotion.h2>\n\n      \u003CAnimatePresence>\n        {expanded && (\n          \u003Cmotion.p\n            key=\"body\"\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0 }}\n            transition={{ duration: motionTokens.duration.fast }}\n          >\n            {body}\n          \u003C\u002Fmotion.p>\n        )}\n      \u003C\u002FAnimatePresence>\n    \u003C\u002Fmotion.div>\n  )\n}\n```\n\n### Shared-element crossfade\n\n```tsx\n\u002F\u002F Source context\n\u003Cmotion.img layoutId=\"hero-image\" src={src} className=\"w-16 h-16 rounded\" \u002F>\n\n\u002F\u002F Destination context (same layoutId — motion handles the transition)\n\u003Cmotion.img layoutId=\"hero-image\" src={src} className=\"w-full rounded-xl\" \u002F>\n```\n\n### Accordion\n\n```tsx\n\u003Cmotion.div\n  initial={false}\n  animate={{ opacity: open ? 1 : 0, scaleY: open ? 1 : 0 }}\n  style={{ transformOrigin: \"top\", overflow: \"hidden\" }}\n  transition={{\n    duration: motionTokens.duration.normal,\n    ease: motionTokens.easing.smooth,\n  }}\n> {children}\n\u003C\u002Fmotion.div>\n```\n\n## End-to-End Example\n\nA staggered list that enters on mount, handles conditional presence, and\nrespects reduced motion — combining tokens, springs, AnimatePresence, and\nthe accessibility hook from `motion-foundations`:\n\n```tsx\n\"use client\"\nimport { useState } from \"react\"\nimport { motion, AnimatePresence } from \"motion\u002Freact\"\nimport { motionTokens, springs } from \"@\u002Flib\u002Fmotion-tokens\"\nimport { useSafeMotion } from \"@\u002Fhooks\u002Fuse-reduced-motion\"\n\nconst containerVariants = {\n  hidden: {},\n  visible: {\n    transition: { staggerChildren: 0.08, delayChildren: 0.1 },\n  },\n}\n\nfunction ListItem({ label, onRemove }: { label: string; onRemove: () => void }) {\n  const safe = useSafeMotion(motionTokens.distance.sm)\n  return (\n    \u003Cmotion.li\n      variants={{\n        hidden:  safe.initial,\n        visible: safe.animate,\n      }}\n      exit={safe.exit}\n      transition={springs.gentle}\n      className=\"flex items-center justify-between p-3 rounded-lg bg-white shadow-sm\"\n    >\n      \u003Cspan>{label}\u003C\u002Fspan>\n      \u003Cbutton onClick={onRemove}>Remove\u003C\u002Fbutton>\n    \u003C\u002Fmotion.li>\n  )\n}\n\nexport function AnimatedList({ items, onRemove }: {\n  items: { id: string; label: string }[]\n  onRemove: (id: string) => void\n}) {\n  return (\n    \u003Cmotion.ul\n      variants={containerVariants}\n      initial=\"hidden\"\n      animate=\"visible\"\n      className=\"space-y-2\"\n    >\n      \u003CAnimatePresence mode=\"popLayout\">\n        {items.map((item) => (\n          \u003CListItem\n            key={item.id}\n            label={item.label}\n            onRemove={() => onRemove(item.id)}\n          \u002F>\n        ))}\n      \u003C\u002FAnimatePresence>\n    \u003C\u002Fmotion.ul>\n  )\n}\n```\n\n## Constraints \u002F Non-Goals\n\nThis skill does **not** cover:\n\n- Token and spring definitions → see `motion-foundations`\n- Drag interactions, swipe gestures, reorderable lists → see `motion-advanced`\n- Text animations (word\u002Fcharacter reveal, counters) → see `motion-advanced`\n- SVG path drawing or morphing → see `motion-advanced`\n- Custom animation hooks → see `motion-advanced`\n- CSS-only transitions not using `motion\u002Freact`\n\n## Anti-Patterns\n\n| Anti-pattern | Rule violated | Fix |\n| -------------------------------------------- | ------- | ------------------------------------------ |\n| `AnimatePresence` child missing `key` | Rule 1 | Add stable `key` to the direct child |\n| `initial` + `animate` without `exit` | Rule 2 | Always define all three together |\n| Page transition without `mode=\"wait\"` | Rule 3 | Add `mode=\"wait\"` to `AnimatePresence` |\n| `layout` on a 50-item list | Rule 4 | Use `mode=\"popLayout\"` or explicit transforms |\n| `staggerChildren: 0.2` on a 10-item list | Rule 5 | Cap at `0.08–0.10` |\n| Modal without focus trap | Rule 6 | Add `focus-trap-react` or Radix Dialog |\n| `whileInView` without `viewport={{ once: true }}` | Rule 7 | Repeating entrances distract, not inform |\n| `transition={{ duration: 0.3 }}` inline | Rule 8 | Use `motionTokens.duration.normal` |\n\n## Related Skills\n\n- **`motion-foundations`** — defines all tokens, springs, the `useSafeMotion` hook, and SSR guards that every pattern here imports. Must be set up first.\n- **`motion-advanced`** — extends these patterns with drag, gestures, SVG, text, custom hooks, and imperative sequencing. Does not redefine any patterns from this skill.\n","# Motion Patterns\n\nCopy-paste patterns for the most common UI animation needs.\nEvery pattern here is built on `motion-foundations` tokens and springs.\nDo not define new duration or easing values here — import them.\n\n## When to Activate\n\n- Animating a button, card, modal, or toast notification\n- Building list entrances with stagger\n- Setting up page transitions in Next.js App Router\n- Adding entrance or exit animations to conditional content\n- Implementing scroll-reveal, scroll-linked progress, or sticky story sections\n- Building expanding cards, accordions, or shared-element transitions\n\n## Outputs\n\nThis skill produces:\n\n- Accessible, SSR-safe animation for all standard UI components\n- `AnimatePresence`-wrapped conditional renders with correct exit behavior\n- Page transition wrapper component for Next.js App Router\n- Scroll-reveal and scroll-linked patterns using `useScroll` + `useTransform`\n- Layout animation patterns (`layout`, `layoutId`) for expanding and crossfading elements\n\n## Principles\n\n- Every pattern imports from `motion-foundations`. No raw numbers.\n- Every conditional render is wrapped in `AnimatePresence` with a `key`.\n- Exit animations are always defined alongside enter animations — never as an afterthought.\n- `layout` is used only for small, isolated shifts. Large subtrees get explicit transforms.\n\n## Rules\n\n1. **Always wrap conditional renders in `AnimatePresence` with a `key`** on the direct child. Without a key, exit animations never fire.\n2. **Always define `exit` when defining `initial` + `animate`.** An animation without an exit is incomplete.\n3. **Use `mode=\"wait\"` on page transitions.** Enter must not start until exit completes.\n4. **Never use `layout` on subtrees with more than ~5 children or deeply nested DOM.** Use explicit `x`\u002F`y` transforms instead.\n5. **Stagger interval must stay between `0.05s` and `0.10s`.** Below feels mechanical; above feels sluggish.\n6. **Modals must always include:** focus trap, Escape-key close, scroll lock, `role=\"dialog\"`, `aria-modal=\"true\"`.\n7. **Scroll reveals use `viewport={{ once: true }}`.** Repeating on scroll-out is distracting, not informative.\n8. **All token values are imported from `motion-foundations`.** No inline numbers.\n\n## Decision Guidance\n\n### Choosing the right pattern\n\n| Situation | Pattern |\n| ---------------------------------------- | ---------------------- |\n| Element appears \u002F disappears             | `AnimatePresence`      |\n| List of items loading in sequence        | Stagger variants       |\n| Navigating between routes                | Page transition wrapper|\n| Element changes size in place            | `layout` prop          |\n| Same element moves across page contexts  | `layoutId`             |\n| Element enters when scrolled into view   | `whileInView`          |\n| Value tied to scroll position            | `useScroll` + `useTransform` |\n\n### When to use `mode=\"wait\"` vs `mode=\"sync\"`\n\n| Mode | Use when |\n| ------- | --------------------------------------- |\n| `wait` | Page transitions, content swaps (one at a time) |\n| `sync` | Stacked notifications, list items (overlap is fine) |\n| `popLayout` | Items removed from a reflow list |\n\n## Core Concepts\n\n### AnimatePresence contract\n\nThree things must always be true:\n\n1. `AnimatePresence` wraps the conditional\n2. The direct child has a `key`\n3. The child has an `exit` prop\n\nMiss any one of these and the exit animation silently fails.\n\n### layout vs layoutId\n\n- `layout` — animates the element's own size\u002Fposition change in place\n- `layoutId` — links two separate elements, crossfading between them across renders\n\nUse `layout=\"position\"` on text inside an expanding container to prevent text reflow from animating.\n\n## Code Examples\n\n### Button feedback\n\n```tsx\n\"use client\"\nimport { motion } from \"motion\u002Freact\"\nimport { springs, motionTokens } from \"@\u002Flib\u002Fmotion-tokens\"\n\n\u003Cmotion.button\n  whileHover={{ scale: motionTokens.scale.pop }}\n  whileTap={{ scale: motionTokens.scale.press }}\n  transition={springs.snappy}\n\u002F>\n```\n\n### Stagger list\n\n```tsx\n\"use client\"\nimport { motion } from \"motion\u002Freact\"\nimport { motionTokens, springs } from \"@\u002Flib\u002Fmotion-tokens\"\n\nconst container = {\n  hidden: {},\n  visible: {\n    transition: {\n      staggerChildren: 0.08,   \u002F\u002F within the 0.05–0.10 rule\n      delayChildren: 0.1,\n    },\n  },\n}\n\nconst item = {\n  hidden:  { opacity: 0, y: motionTokens.distance.md },\n  visible: { opacity: 1, y: 0, transition: springs.gentle },\n}\n\n\u003Cmotion.ul variants={container} initial=\"hidden\" animate=\"visible\">\n  {items.map((i) => (\n    \u003Cmotion.li key={i.id} variants={item} \u002F>\n  ))}\n\u003C\u002Fmotion.ul>\n```\n\n### Modal\n\n```tsx\n\"use client\"\nimport { motion, AnimatePresence } from \"motion\u002Freact\"\nimport { motionTokens, springs } from \"@\u002Flib\u002Fmotion-tokens\"\n\n\u002F\u002F Wrap at the call site:\n\u002F\u002F \u003CAnimatePresence>{isOpen && \u003CModal key=\"modal\" \u002F>}\u003C\u002FAnimatePresence>\n\nexport function Modal({ onClose }: { onClose: () => void }) {\n  return (\n    \u003C>\n      {\u002F* Overlay *\u002F}\n      \u003Cmotion.div\n        className=\"fixed inset-0 bg-black\u002F50\"\n        initial={{ opacity: 0 }}\n        animate={{ opacity: 1 }}\n        exit={{ opacity: 0 }}\n        onClick={onClose}\n      \u002F>\n\n      {\u002F* Panel — accessibility requirements: focus trap, Escape close,\n          scroll lock, role=\"dialog\", aria-modal=\"true\" *\u002F}\n      \u003Cmotion.div\n        role=\"dialog\"\n        aria-modal=\"true\"\n        className=\"fixed inset-x-4 top-1\u002F2 -translate-y-1\u002F2 rounded-xl bg-white p-6\"\n        initial={{\n          opacity: 0,\n          scale: motionTokens.scale.press,\n          y: motionTokens.distance.sm,\n        }}\n        animate={{ opacity: 1, scale: 1, y: 0 }}\n        exit={{\n          opacity: 0,\n          scale: motionTokens.scale.press,\n          y: motionTokens.distance.sm,\n        }}\n        transition={springs.gentle}\n      \u002F>\n    \u003C\u002F>\n  )\n}\n```\n\n### Toast stack\n\n```tsx\n\"use client\"\nimport { motion, AnimatePresence } from \"motion\u002Freact\"\nimport { motionTokens, springs } from \"@\u002Flib\u002Fmotion-tokens\"\n\n\u003CAnimatePresence mode=\"sync\">\n  {toasts.map((t) => (\n    \u003Cmotion.div\n      key={t.id}\n      layout\n      initial={{\n        opacity: 0,\n        x: motionTokens.distance.xl,\n        scale: motionTokens.scale.subtle,\n      }}\n      animate={{ opacity: 1, x: 0, scale: 1 }}\n      exit={{\n        opacity: 0,\n        x: motionTokens.distance.xl,\n        scale: motionTokens.scale.subtle,\n      }}\n      transition={springs.snappy}\n    \u002F>\n  ))}\n\u003C\u002FAnimatePresence>\n```\n\n### Page transition (Next.js App Router)\n\n```tsx\n\u002F\u002F components\u002Fpage-transition.tsx\n\"use client\"\nimport { motion, AnimatePresence } from \"motion\u002Freact\"\nimport { usePathname } from \"next\u002Fnavigation\"\nimport { motionTokens } from \"@\u002Flib\u002Fmotion-tokens\"\n\nconst variants = {\n  initial: { opacity: 0, y: motionTokens.distance.sm },\n  enter:   { opacity: 1, y: 0 },\n  exit:    { opacity: 0, y: -motionTokens.distance.sm },\n}\n\nexport function PageTransition({ children }: { children: React.ReactNode }) {\n  const pathname = usePathname()\n  return (\n    \u003CAnimatePresence mode=\"wait\">\n      \u003Cmotion.div\n        key={pathname}\n        variants={variants}\n        initial=\"initial\"\n        animate=\"enter\"\n        exit=\"exit\"\n        transition={{\n          duration: motionTokens.duration.normal,\n          ease: motionTokens.easing.smooth,\n        }}\n      >\n        {children}\n      \u003C\u002Fmotion.div>\n    \u003C\u002FAnimatePresence>\n  )\n}\n```\n\n### Scroll reveal\n\n```tsx\n\"use client\"\nimport { motion } from \"motion\u002Freact\"\nimport { motionTokens, springs } from \"@\u002Flib\u002Fmotion-tokens\"\n\n\u003Cmotion.div\n  initial={{ opacity: 0, y: motionTokens.distance.lg }}\n  whileInView={{ opacity: 1, y: 0 }}\n  viewport={{ once: true, margin: \"-80px\" }}   \u002F\u002F once: true — rule 7\n  transition={{ duration: motionTokens.duration.slow, ease: motionTokens.easing.smooth }}\n\u002F>\n```\n\n### Scroll progress bar\n\n```tsx\n\"use client\"\nimport { motion, useScroll } from \"motion\u002Freact\"\n\nexport function ScrollProgress() {\n  const { scrollYProgress } = useScroll()\n  return (\n    \u003Cmotion.div\n      className=\"fixed top-0 left-0 h-1 bg-indigo-500 origin-left w-full\"\n      style={{ scaleX: scrollYProgress }}\n    \u002F>\n  )\n}\n```\n\n### Expanding card\n\n```tsx\n\"use client\"\nimport { useState } from \"react\"\nimport { motion, AnimatePresence } from \"motion\u002Freact\"\nimport { springs, motionTokens } from \"@\u002Flib\u002Fmotion-tokens\"\n\nexport function ExpandingCard({ title, body }: { title: string; body: string }) {\n  const [expanded, setExpanded] = useState(false)\n\n  return (\n    \u003Cmotion.div layout onClick={() => setExpanded(!expanded)} className=\"cursor-pointer\">\n      {\u002F* layout=\"position\" prevents text reflow from animating *\u002F}\n      \u003Cmotion.h2 layout=\"position\" className=\"font-semibold\">\n        {title}\n      \u003C\u002Fmotion.h2>\n\n      \u003CAnimatePresence>\n        {expanded && (\n          \u003Cmotion.p\n            key=\"body\"\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0 }}\n            transition={{ duration: motionTokens.duration.fast }}\n          >\n            {body}\n          \u003C\u002Fmotion.p>\n        )}\n      \u003C\u002FAnimatePresence>\n    \u003C\u002Fmotion.div>\n  )\n}\n```\n\n### Shared-element crossfade\n\n```tsx\n\u002F\u002F Source context\n\u003Cmotion.img layoutId=\"hero-image\" src={src} className=\"w-16 h-16 rounded\" \u002F>\n\n\u002F\u002F Destination context (same layoutId — motion handles the transition)\n\u003Cmotion.img layoutId=\"hero-image\" src={src} className=\"w-full rounded-xl\" \u002F>\n```\n\n### Accordion\n\n```tsx\n\u003Cmotion.div\n  initial={false}\n  animate={{ opacity: open ? 1 : 0, scaleY: open ? 1 : 0 }}\n  style={{ transformOrigin: \"top\", overflow: \"hidden\" }}\n  transition={{\n    duration: motionTokens.duration.normal,\n    ease: motionTokens.easing.smooth,\n  }}\n> {children}\n\u003C\u002Fmotion.div>\n```\n\n## End-to-End Example\n\nA staggered list that enters on mount, handles conditional presence, and\nrespects reduced motion — combining tokens, springs, AnimatePresence, and\nthe accessibility hook from `motion-foundations`:\n\n```tsx\n\"use client\"\nimport { useState } from \"react\"\nimport { motion, AnimatePresence } from \"motion\u002Freact\"\nimport { motionTokens, springs } from \"@\u002Flib\u002Fmotion-tokens\"\nimport { useSafeMotion } from \"@\u002Fhooks\u002Fuse-reduced-motion\"\n\nconst containerVariants = {\n  hidden: {},\n  visible: {\n    transition: { staggerChildren: 0.08, delayChildren: 0.1 },\n  },\n}\n\nfunction ListItem({ label, onRemove }: { label: string; onRemove: () => void }) {\n  const safe = useSafeMotion(motionTokens.distance.sm)\n  return (\n    \u003Cmotion.li\n      variants={{\n        hidden:  safe.initial,\n        visible: safe.animate,\n      }}\n      exit={safe.exit}\n      transition={springs.gentle}\n      className=\"flex items-center justify-between p-3 rounded-lg bg-white shadow-sm\"\n    >\n      \u003Cspan>{label}\u003C\u002Fspan>\n      \u003Cbutton onClick={onRemove}>Remove\u003C\u002Fbutton>\n    \u003C\u002Fmotion.li>\n  )\n}\n\nexport function AnimatedList({ items, onRemove }: {\n  items: { id: string; label: string }[]\n  onRemove: (id: string) => void\n}) {\n  return (\n    \u003Cmotion.ul\n      variants={containerVariants}\n      initial=\"hidden\"\n      animate=\"visible\"\n      className=\"space-y-2\"\n    >\n      \u003CAnimatePresence mode=\"popLayout\">\n        {items.map((item) => (\n          \u003CListItem\n            key={item.id}\n            label={item.label}\n            onRemove={() => onRemove(item.id)}\n          \u002F>\n        ))}\n      \u003C\u002FAnimatePresence>\n    \u003C\u002Fmotion.ul>\n  )\n}\n```\n\n## Constraints \u002F Non-Goals\n\nThis skill does **not** cover:\n\n- Token and spring definitions → see `motion-foundations`\n- Drag interactions, swipe gestures, reorderable lists → see `motion-advanced`\n- Text animations (word\u002Fcharacter reveal, counters) → see `motion-advanced`\n- SVG path drawing or morphing → see `motion-advanced`\n- Custom animation hooks → see `motion-advanced`\n- CSS-only transitions not using `motion\u002Freact`\n\n## Anti-Patterns\n\n| Anti-pattern | Rule violated | Fix |\n| -------------------------------------------- | ------- | ------------------------------------------ |\n| `AnimatePresence` child missing `key` | Rule 1 | Add stable `key` to the direct child |\n| `initial` + `animate` without `exit` | Rule 2 | Always define all three together |\n| Page transition without `mode=\"wait\"` | Rule 3 | Add `mode=\"wait\"` to `AnimatePresence` |\n| `layout` on a 50-item list | Rule 4 | Use `mode=\"popLayout\"` or explicit transforms |\n| `staggerChildren: 0.2` on a 10-item list | Rule 5 | Cap at `0.08–0.10` |\n| Modal without focus trap | Rule 6 | Add `focus-trap-react` or Radix Dialog |\n| `whileInView` without `viewport={{ once: true }}` | Rule 7 | Repeating entrances distract, not inform |\n| `transition={{ duration: 0.3 }}` inline | Rule 8 | Use `motionTokens.duration.normal` |\n\n## Related Skills\n\n- **`motion-foundations`** — defines all tokens, springs, the `useSafeMotion` hook, and SSR guards that every pattern here imports. Must be set up first.\n- **`motion-advanced`** — extends these patterns with drag, gestures, SVG, text, custom hooks, and imperative sequencing. Does not redefine any patterns from this skill.\n",{"name":5,"tags":23,"author":27,"category":28,"metadata":29,"description":7},[24,25,26],"motion","animation","ui-patterns","jeff","frontend",{"version":30},"1.0.0","main","7542b2fc80051758dfb288b450cb344d3bdfca35","curation\u002Fskills\u002Fmotion-patterns",0,"https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified","https:\u002F\u002Fgithub.com\u002FMoradDev","2026-11-07 21:53:24",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add MoradDev\u002Fskills-unified --skill motion-patterns",{"tool":44,"command":45},"bunx","bunx skills add MoradDev\u002Fskills-unified --skill motion-patterns",{"tool":47,"command":48},"pnpm","pnpm dlx skills add MoradDev\u002Fskills-unified --skill motion-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fmotion-patterns\u002FSKILL.md",true,[],[53,60,67,74,81,88],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":18},"01M7DB9J6N2PSGECQ6FTWW7B2H","windows-desktop-e2e","E2E testing for Windows native desktop apps (WPF, WinForms, Win32\u002FMFC, Qt) using pywinauto and Windows UI Automation. Use when writing E2E tests for a Windows native desktop app with pywinauto or UI Automation.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fwindows-desktop-e2e\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":18},"01M7DB9CCWT4YW7B791QN43E3Q","vue-patterns","Vue.js 3 Composition API patterns, component architecture, reactivity best practices, Pinia state management, Vue Router navigation, and Nuxt SSR patterns. Activates for Vue, Nuxt, Vite, or Pinia projects. Use when building or reviewing Vue 3, Nuxt, or Pinia code — Composition API, reactivity, or router navigation.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fvue-patterns\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M7DB976FM2CAWT807EA36MXM","vite-patterns","Vite build tool patterns including config, plugins, HMR, env variables, proxy setup, SSR, library mode, dependency pre-bundling, and build optimization. Activate when working with vite.config.ts, Vite plugins, or Vite-based projects.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fvite-patterns\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":18},"01M7DB93JZRAWFB5QHH0C8DZ8N","using-agent-skills","Discovers and invokes agent skills. Use when starting a session, or when you need to decide which skill or workflow applies to the piece of work at hand. This is the meta-skill that governs how all other skills are discovered and invoked.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fusing-agent-skills\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":18},"01M7DB8YYW1PEDS7H2AA86TE2E","ui-demo","Record polished UI demo videos using Playwright. Use when the user asks to create a demo, walkthrough, screen recording, or tutorial video of a web application. Produces WebM videos with visible cursor, natural pacing, and professional feel.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fui-demo\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":18},"01M7DB8RPQPW2R6GKJW618VDST","swiftui-patterns","SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS\u002FmacOS UI best practices. Use when building or reviewing SwiftUI views, @Observable state, navigation, or render performance.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fswiftui-patterns\u002FSKILL.md",[],[]]