Chapter 125: Vue animations with Motion for Vue
Core Idea
Animate UIs in Motion for Vue with motion components. Animate CSS, transforms, & SVGs. Use variants for orchestration, gestures, and keyframes.
Key Concepts
- Basic animations: You'll perform almost all animations on a <motion /> component.
- Animatable values: Motion can animate any CSS value
- Value type conversion: In general
- Transforms: Unlike CSS
- Transform origin: transform-origin has three shortcut values that can be set and animated individually:
- CSS variables: Motion for Vue can animate the value of CSS variables
- Animating CSS variables: Sometimes it's convenient to be able to animate a CSS variable to animate many children:
- CSS variables as animation targets: HTML motion components accept animation targets with CSS variables:
- SVG line drawing: Line drawing animations can be created with many different SVG elements using three specia
Code Examples
import { motion } from "motion-v"
- What it demonstrates: Core usage pattern for Vue animations with Motion for Vue.
Key Takeaways
- Numbers:
0, 100 etc.
- Strings containing numbers:
"0vh", "10px" etc.
- Colors: Hex, RGBA, HSLA.
- Complex strings containing multiple numbers and/or colors (like
box-shadow).
display: "none"/"block" and visibility: "hidden"/"visible".
Connects To
- Vue <motion /> component: related Motion doc page.
- Motion values: related Motion doc page.
- Vue transitions: related Motion doc page.
- AnimatePresence: related Motion doc page.
- useAnimate: related Motion doc page.