Motion v skilld
Skill skilld-dev/vue-ecosystem-skills/skills/motion-v-skilld
ALWAYS use when writing code importing "motion-v". Consult for debugging, best practices, or modifying motion-v, motion v, motion-vue, motion vue.From its SKILL.md
npx -y skills add skilld-dev/vue-ecosystem-skills --skill motion-v-skilldAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
6.5 KB, as published. Nobody here has run it
motiondivision/motion-vue [email protected]
Tags: latest: 2.2.1
References: Docs
API Changes
This section documents version-specific API changes — prioritize recent major/minor releases.
-
BREAKING:
focus,hover,press,inViewshorthand props — removed in v2.0.0-beta.1. UsewhileFocus,whileHover,whilePress, andwhileInViewfor animations, and full event handlers (e.g.@hoverStart,@pressStart) for logic source -
NEW:
v-motiondirective — new in v2.0.0-beta.1, enables declarative animations on any element without requiring a<motion>component wrapper source -
BREAKING: ESM-only — v2.0.0-beta.1 dropped CommonJS support. The package now only ships ESM (
.mjs) exports source -
NEW:
MotionPlugin— new in v2.0.0-beta.1, a Vue plugin for globalv-motionand custom preset directive registration -
NEW:
createPresetDirective()— new in v2.0.0-beta.1, allows creating reusable animation directives with baked-in motion options -
BREAKING:
AnimatePresencelazy discovery — v2.0.0-beta.1 refactored to usedata-apattribute for lazy discovery instead of eager registration source -
DEPRECATED:
staggerChildrenandstaggerDirection— deprecated in v1.4.0 in favor of using thestagger()utility within thetransitionprop source -
NEW:
stagger()utility — correctly handles staggering for newly-entering siblings alongside existing ones since v1.7.0 source -
NEW:
useTransformoutput maps — supports providing multiple output value maps for complex coordinate transformations since v1.9.0 source -
NEW:
Reorderauto-scrolling — supports automatic parent container scrolling when aReorder.Itemis dragged to the edges since v1.8.0 source -
NEW:
useScrollVueInstance support —containerandtargetoptions now acceptVueInstance(ref to component) since v1.6.0 source -
NEW:
useInViewrootoption — now acceptsMaybeReffor dynamic root element assignment since v1.6.0 source -
NEW:
AnimatePresencedirect children — supports multiple directmotioncomponents as children since v1.10.0 source -
NEW:
delayInMs— exported as a standalone utility function for time-based animation delays since v1.6.0 source
Also changed: useTransform reactive update fix (v1.2.1) · sequence at relative start (v1.3.0) · AnimatePresence custom prop fix (v1.3.0) · motionGlobalConfig exported (v2.0.0-beta.1) · FeatureBundle tree-shaking architecture (v2.0.0-beta.1)
Best Practices
-
Use
LazyMotion+mcomponent instead ofmotionto reduce the initial bundle from ~34kb to ~6kb — loaddomAnimation(+18kb) for variants/exit/gestures ordomMax(+28kb) when you also need drag and layout animations. Add:strict="true"to catch accidentalmotionimports insideLazyMotionat dev time source -
Render live motion value output with
<RowValue :value="motionValue" />rather than syncing to Vue state —RowValuewrites toinnerHTMLdirectly and bypasses Vue's reactivity cycle, keeping fast-changing values off the render path source -
Set
reducedMotion="user"onMotionConfigat the app root — the default is"never", meaning transform and layout animations run regardless of the OS accessibility setting unless you explicitly opt in source -
For layout animations, apply changing CSS to
:style(not:animate) and let thelayoutprop handle the transition — if the value is placed in:animate, Motion's FLIP measurement will conflict with it source -
Set
borderRadiusandboxShadowvia:style(not CSS classes) onlayout-animated elements — Motion auto-corrects scale distortion on these properties only when they are set as inline style motion values source -
Add
layoutScrollto scrollable container ancestors andlayoutRootto fixed-position ancestors of layout-animated elements — without these props, Motion measures child positions incorrectly when scroll offset or viewport offset is non-zero source -
Never place
v-ifonAnimatePresenceitself — if it unmounts, it cannot intercept the exit of its children. The conditional must be on the direct child:
<AnimatePresence v-if="isVisible"><Component /></AnimatePresence>
<AnimatePresence><Component v-if="isVisible" /></AnimatePresence>
-
Use dynamic variants with the
customprop for per-element stagger rather than computing delay in reactive Vue state — pass:custom="index"to eachmotioncomponent and resolve the delay inside the variant function, keeping stagger logic declarative and allocation-free source -
Prefer
useMotionValueover CSS variable animation for values used across many children — animating a CSS variable always triggers paint on every frame, while aMotionValuepassed to:styleruns through Motion's optimised DOM renderer without touching the Vue render cycle source -
Use the
v-motiondirective (new in v2.0.0-beta.1) to add animation to any native HTML or SVG element without a wrapper<motion>component — register globally viaapp.use(MotionPlugin)or per-component viacreateMotionDirective. Register reusable animation presets via thepresetsoption to create project-wide shorthand directives likev-fade-insource