Motion guide · 3 of 8
States and lists
Components also animate while they're on screen, such as on a press, a failed check or a panel opening. Lists animate items as they come and go.
Press and hover
states animates a part while the component is in a state. A plain value holds while the state is on: active: { root: { scale: '0.92' } } shrinks a button while you press it. Any element takes the same looks through v-animate: { states: { hover: { scale: 1.03 }, active: { scale: 0.97 } } }. The states every component and element has: hover (a mouse only, never a tap), active (pressed by a pointer, Space or Enter) and focus (focus anywhere inside it). Components add their own, such as invalid, checked, open or disabled, listed on each component's page, and v-animate adds inView.
A failed check
An array plays once, as the state turns on: invalid: { root: { x: [0, -8, 8, -4, 4, 0] } } shakes a field each time it becomes invalid.
Open, checked, pressed
Accordion turns its chevron in open, and Switch squashes its thumb in active. Each component page lists its parts and states under Motion.
Keyframes
An array is a set of keyframes. times places each one, from 0 to 1, and easing eases each step. Pass a list of easings to give each step its own, such as a rise and then a bounce. repeat plays them again, and repeat: Infinity keeps going until the state turns off or the look changes. A step can ease on a spring: easing: ['linear', 'bouncy']. Change a loop's duration while it plays, and it speeds up or slows down from where it is. repeatDelay holds still between runs, and repeatType: 'mirror' comes back the way it went. null as the first keyframe starts from wherever the value is now: scale: [null, 1.2, 1].
One at a time
Some parts repeat, such as a Stepper's circles, a Dock's items or an OtpInput's cells. Each element plays its own states, so only the step that becomes current pops. Write the values as a function to use each element's index, such as for a shake that ripples cell by cell.
Play the entrance again
A component's motion takes replay too. When it changes, the component plays its initial again without remounting, such as a burst of stars on a five-star rating. appear: false stops it from playing when the component mounts. A state takes replay too: while it's on, a new value plays its keyframes again, so a second wrong code shakes the field again: invalid: { root: { x: [0, -6, 6, 0] }, replay: attempts }.
Lists
Toaster, Timeline, FileUpload, SpeedDial, DataTable rows, CommandPalette rows and the Select family's chips bring new items in one after another. leaving: 'pop' lifts a leaving item out of the layout, so the rest close the gap at once. 'hold' keeps the gap until the item is gone. Write initial or exit as a function to receive { index, count } for the items arriving or leaving together, so a close can run last to first. stagger takes the same words as on v-animate (true, 'end', 'center', 'edges'), or seconds.
A toast that changes
Toaster's states play when a toast changes variant. A saving toast that ends in error can shake, and one that ends in success can pop its icon.