Motion Plus Vue Components
Motion Plus Vue (current stable version 1.8.1) is a Vue 3 component library that extends the capabilities of the core `motion-v` animation engine. It primarily focuses on providing specialized, high-performance animation components, such as `AnimateNumber`, for modern Vue applications. While `motion-v` (version 2.x, the official 'Motion for Vue' library) offers general-purpose animation primitives like the `<motion>` component and `v-motion` directive, `motion-plus-vue` provides ready-to-use, often complex, UI animation patterns building upon `motion-v`. Its release cadence is not explicitly stated, but the version number indicates active maintenance. A key differentiator is its focus on specific, advanced animation components that are part of the broader 'Motion Plus' ecosystem, leveraging the underlying `motion-v` for hardware-accelerated and smooth user interfaces.
Common errors
-
Failed to resolve component: AnimateNumber
cause The AnimateNumber component was not correctly imported or registered in your Vue application.fixEnsure you have `import { AnimateNumber } from 'motion-plus-vue'` in your script setup or component options, and that `motion-plus-vue` is correctly installed. -
Peer dependency 'motion-v@^2.0.0' not installed or not met
cause The required peer dependency 'motion-v' at version 2.x is missing or an incompatible version is installed.fixRun `npm install motion-v@^2.0.0` or `yarn add motion-v@^2.0.0` to install the correct peer dependency. -
TypeError: Cannot read properties of undefined (reading 'install')
cause Attempting to use `app.use()` with a non-plugin or an incorrectly imported plugin. The core `MotionPlugin` comes from `motion-v`, not `motion-plus-vue` directly.fixEnsure you are importing and using `MotionPlugin` correctly from `motion-v` if you intend to register global directives. Components from `motion-plus-vue` are typically imported and used directly in templates. -
TS2307: Cannot find module 'motion-plus-vue' or its corresponding type declarations.
cause TypeScript compiler cannot locate the package or its type definitions, or the package is not installed.fixEnsure 'motion-plus-vue' is installed (`npm install motion-plus-vue`) and your `tsconfig.json` correctly includes `"allowSyntheticDefaultImports": true` and `"esModuleInterop": true` if you are using default imports, though named imports are preferred for this library.
Warnings
- breaking This package is strictly built for Vue 3. Using it with Vue 2.x will result in runtime errors due to fundamental API changes.
- breaking Requires 'motion-v' version 2.0.0 or higher as a peer dependency. Older versions of 'motion-v' will not provide the necessary APIs, leading to runtime failures.
- gotcha The `AnimateNumber` component, prominently featured by `motion-plus-vue`, is noted in `motion.dev` documentation as an 'exclusive to Motion+ members' feature. This may imply a requirement for a `motion-plus` package and a private token for installation or usage.
- gotcha Animation libraries can sometimes cause issues with Server-Side Rendering (SSR) if not handled correctly. Ensure client-side-only animations are properly guarded (e.g., using `client-only` component in Nuxt or dynamic imports).
- gotcha Performance can be impacted if complex animations are applied to a large number of elements or frequently updated. Monitor frame rates and optimize animations.
Install
-
npm install motion-plus-vue -
yarn add motion-plus-vue -
pnpm add motion-plus-vue
Imports
- AnimateNumber
import AnimateNumber from 'motion-plus-vue'
import { AnimateNumber } from 'motion-plus-vue' - MotionPlugin
import { MotionPlugin } from 'motion-plus-vue'import { MotionPlugin } from 'motion-v' - v-motion
import { vMotion } from 'motion-plus-vue'import { vMotion } from 'motion-v'
Quickstart
<!-- App.vue -->
<script setup lang="ts">
import { ref } from 'vue';
// AnimateNumber is typically imported directly from motion-plus-vue
import { AnimateNumber } from 'motion-plus-vue';
const count = ref(0);
const increment = () => {
count.value++;
};
const decrement = () => {
if (count.value > 0) {
count.value--;
}
};
</script>
<template>
<div class="container">
<h1>Current Value: <AnimateNumber>{{ count }}</AnimateNumber></h1>
<div class="controls">
<button @click="increment">Increment</button>
<button @click="decrement">Decrement</button>
</div>
<p>
This example demonstrates the <code><AnimateNumber></code> component from <code>motion-plus-vue</code>.
It animates the numeric value smoothly when the underlying `count` ref changes.
The component internally leverages the <code>motion-v</code> animation engine for its effects.
</p>
</div>
</template>
<style scoped>
.container {
font-family: sans-serif;
text-align: center;
padding: 20px;
border: 1px solid #eee;
border-radius: 8px;
max-width: 400px;
margin: 50px auto;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
h1 {
margin-bottom: 20px;
color: #333;
}
.controls button {
background-color: #42b983;
color: white;
border: none;
padding: 10px 20px;
margin: 0 10px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
.controls button:hover {
background-color: #368d6f;
}
.controls button:active {
background-color: #2b745a;
}
p {
margin-top: 30px;
font-size: 0.9em;
color: #666;
line-height: 1.5;
}
</style>