Motion
Every duration, curve and spring, each one played on a real surface.
Motion says what changed: where a layer came from, which control answered, what moved and where it went. It is short, and the more often a thing happens the less of it there is.
Press a play button to send a surface to the other end of its track, and again to bring it back. Pressed half way, the surface turns round from where it is. "Play all" sends a whole table at once, so its rows can be compared.
With reduced motion set on your device nothing on this page moves: a played surface fades out at one end of its track and in at the other.
Durations
Six lengths of time. Something leaving is faster than the same thing arriving.
Each plays on --ease-standard, over the same distance.
120ms160ms180ms240msspring.smooth takes.400ms480msCurves
A curve is the shape of a change over its duration. What arrives, or answers a hand, starts fast and settles. What leaves starts slowly and is gone.
A curve with a class beside its name is a Tailwind ease-* utility. The others, and
every duration, are read with var().
Each plays over --duration-considered, the longest duration.
cubic-bezier(0.16, 1, 0.3, 1)cubic-bezier(0.7, 0, 0.84, 0)cubic-bezier(0.22, 1, 0.36, 1)cubic-bezier(0.65, 0, 0.35, 1)ease-out-strongWhat answers a hand: the press of a button, the thumb of a switch.cubic-bezier(0.23, 1, 0.32, 1)ease-in-out-strongA firmer curve for movement on screen.cubic-bezier(0.77, 0, 0.175, 1)ease-drawerSheets, drawers and the release of a pull.cubic-bezier(0.32, 0.72, 0, 1)ease-spring-softPhones only: menus, the tab pill, chevrons, tiles and a swipe settling.cubic-bezier(0.3, 1.3, 0.5, 1)ease-spring-pressPhones only: the swell of a press.cubic-bezier(0.3, 1.6, 0.5, 1)cubic-bezier(0.34, 1.56, 0.64, 1)ease-out-cubicA gentler way out: the bars of the prompt input's usage meter.cubic-bezier(0.215, 0.61, 0.355, 1)ease-out-quintThe curve of --ease-out-strong under a second name, as attachments read it.cubic-bezier(0.23, 1, 0.32, 1)ease-springA spring with no overshoot, written as a curve for a CSS transition: the prompt input's effort slider.linear(0, 0.015 2%, 0.0532 4%, 0.1065 6%, 0.1686 8%, 0.2351 10%, 0.3363 13%, 0.4332 16%, 0.5495 20%, 0.648 24%, 0.7287 28%, 0.807 33%, 0.8646 38%, 0.9128 44%, 0.9447 50%, 0.968 57%, 0.9834 65%, 0.9924 74%, 0.9975 85%, 1).tray {
transition: translate var(--duration-panel) var(--ease-drawer);
}Springs
What is animated with motion/react takes its spring from
motion tokens. None of the three overshoots.
Each is a spring of motion/react, played over the same distance.
type: "spring", visualDuration: 0.26, bounce: 0type: "spring", visualDuration: 0.4, bounce: 0type: "spring", visualDuration: 0.42, bounce: 0An animated element is an m element from motion/react-m, never the full motion
component, and it animates under the motion provider,
which loads what it needs once for the whole app.
import * as m from "motion/react-m"
import { motionTokens } from "@/lib/motion-tokens"
export function Thumb({ on }: { on: boolean }) {
return (
<m.span
animate={{ x: on ? "100%" : "0%" }}
transition={motionTokens.spring.snappy}
/>
)
}Which to use
- A press, a toggle or a thumb takes
spring.snappy. - A panel, or a change of height, takes
spring.smooth. - A highlight shared by tabs or rows takes
spring.morph. - A menu, a popover, a tooltip, a dialog or a sheet is a CSS transition between Base
UI's
[data-starting-style]and[data-ending-style]. A transition can turn round half way, so an overlay closed while it is still opening goes back from where it is. - An overlay arrives over
--duration-standardon--ease-enterand leaves over--duration-exiton--ease-exit: the exit is the faster of the two. - What the keyboard opens many times a day does not animate. The command palette appears and is gone at once.
Reduced motion
Every animation has a second form for prefers-reduced-motion: reduce. Movement, scale
and blur go; fades and changes of colour stay, because they still say that something
changed. Foundation does this for every overlay, and an m element under the motion
provider follows the setting by itself.