Motion
Most motion uses one easing curve, --curve. Nothing bounces. Controls you use often animate less. Menus and popovers open next to the control that opened them. registry/cobalt/lib/motion.ts holds the timings, and a test checks that tokens.css matches it.
The verbs
Press
Pressing a control. It darkens in place and never scales. Press and hold.
140ms on --curve
Settle
A control showing its new state. The new words come in from above while the old ones leave below.
300ms on the settle spring, --curve-settle
Grow
A button that grows into its small form by its real width and height, over the page.
Opens in 450ms on --curve-layout, closes in 300ms on --curve-settle
Pop
A menu, popover, select or tooltip. It fades in beside its control and leaves faster.
150ms in, 105ms out, on --curve
Slide
A sheet over the page, from the side it belongs to. On a phone it rises from the bottom.
450ms in on --curve-sheet, 200ms out
Travel
One element moving between two places, such as the thumb of a segmented control.
300ms on --curve-settle, for the segmented control, tabs and the nav's pill alike
Swap
Content stepping forward or back in the same box, in the direction of the step.
In 8px over 300ms on the settle spring, out in 105ms
Arrive
A new item appearing while you watch, such as someone joining. Never on the first load.
220ms on --curve, from 4px below
Leave
An item being removed. It fades while its height closes, so the rows below close the gap.
200ms fade on --curve, the height in 300ms on --curve-settle
Shake
An input that was turned down. This stand-in turns down every code.
340ms on --curve-shake, 6px each way
Count
A number that changed. Tabular figures keep its width, so nothing beside it moves.
The figures change in place, with no movement
Total$480
Curves
--curvePress 140ms, pop 150ms, leave 200ms, arrive 220ms--curve-settleSettle, Swap, a panel closing and a segmented control's thumb, 300ms--curve-layoutGrow and a panel opening, 450ms--curve-sheetSlide, a sheet opening, 450ms--curve-in-outTwo icons or two wordings swapping, 250ms--curve-shakeShake, five legs on this curve, 340ms in allEach square runs for the time under its plot, on the token itself.
Tokens
--t-pressA press, and a colour change under the pointer140ms--t-popPop: a menu or popover opening; closing takes 70 percent of it150ms--t-fadeA plain fade with nothing moving150ms--t-leaveLeave: something closing, and a sheet sliding out200ms--t-arriveArrive: a new item appearing while you watch, a dialog or a toast opening220ms--t-iconTwo icons, or two wordings, swapping in one place250ms--t-settleSettle and Swap, a panel closing, and every sliding thumb: a segmented control's, the active tab's, the nav's pill300ms--t-crossfadeLarge content changing in place320ms--t-layoutGrow, a panel opening, any change of size450ms--t-sheetSlide: a sheet opening450ms--t-travelTravel: a shared element moving between two places, on the motion library's travel spring500ms--curveEvery colour change, press, pop, arrive and leave, and the nav's pill slidingcubic-bezier(0.23, 1, 0.32, 1)--curve-in-outTwo icons, or two wordings, swapping in one placecubic-bezier(0.77, 0, 0.175, 1)--curve-sheetSlidecubic-bezier(0.32, 0.72, 0, 1)--curve-shakeShakecubic-bezier(0.22, 1, 0.36, 1)--curve-layoutGrow in CSS: the layout spring (--t-layout), sampled every 10ms, so a panel that opens moves as the motion library would move itlinear(0, 0.0192, 0.0669, 0.1317, 0.2054, 0.2824, 0.3586, 0.4317, 0.5001, 0.563, 0.62, 0.6711, 0.7164, 0.7564, 0.7914, 0.8219, 0.8483, 0.8711, 0.8907, 0.9075, 0.9218, 0.9341, 0.9445, 0.9533, 0.9608, 0.9671, 0.9724, 0.9769, 0.9807, 0.9839, 0.9865, 0.9888, 0.9906, 0.9922, 0.9935, 0.9946, 0.9955, 0.9963, 0.9969, 0.9974, 0.9979, 0.9982, 0.9985, 0.9988, 1)--curve-settleSettle in CSS: the settle spring (--t-settle), sampled the same way, for a close or a thumb's slide that never keeps the person waitinglinear(0, 0.0411, 0.1342, 0.2478, 0.3638, 0.4725, 0.5692, 0.6524, 0.7222, 0.7798, 0.8267, 0.8644, 0.8944, 0.9181, 0.9367, 0.9513, 0.9626, 0.9714, 0.9782, 0.9834, 0.9874, 0.9904, 0.9927, 0.9945, 0.9959, 0.9969, 0.9976, 0.9982, 0.9987, 1)
Content changes
IconSwap, TextSwap, Crossfade and Swap change what a box shows while the box keeps its size. Content changes says which one to use.
Presets
| Motion | Use for | Preset |
|---|---|---|
| Press | pressing a control | pressable (the --hover tint on duration-press ease-out) |
| Settle | a control showing its new state, such as a saved button | springs.settle, StateButton |
| Grow | a control that grows into its panel by its real width and height | springs.layout, Grow |
| Pop | menus, popovers, selects and tooltips | popup-motion (duration-pop fade, exit at 70 percent) |
| Slide | a sheet over the page | duration-sheet ease-sheet in, duration-leave out, Sheet |
| Travel | one element moving between two places, such as a selection thumb | springs.travel; in CSS, duration-settle ease-settle on a segmented control's or tabs' thumb and duration-layout ease-out on the nav's pill |
| Swap | content stepping forward or back in the same box | springs.settle in, 70 percent of --t-pop out, Swap |
| Arrive | a new item appearing while you watch | the arrive keyframes in styles.css at --t-arrive |
| Leave | an item being removed | a duration-leave fade while its height closes on duration-settle ease-settle |
| Shake | an input that was rejected | shake from lib/motion.ts |
| Count | a number that changed | tabular-nums, so the width stays the same |
How often
| How often you see it | Allowed motion |
|---|---|
| Hundreds of times a day, such as nav links, tabs, typing, filters, hover | colour changes only, with pressable or duration-press |
| Tens of times a day, such as saving, opening an item, opening a menu | one motion at its standard duration |
| Once a day or less, such as pasting a link, verifying an email, publishing | several motions together, up to about 600ms. Staggered lists go only here. |
