|Kit

Motion

Named curves and durations for every transition, springs that CSS and JavaScript share, and the reduced-motion contract.

Motion in the kit comes from a small set of named tokens: six curves picked by the job a transition does, two spring curves, and a five-step duration scale. They live in theme.css next to the colours, so a transition you write in your app moves the same way the kit's own do.

<div className="transition-transform ease-emphasized duration-(--duration-slow)" />

Every --ease-* token is also a Tailwind ease-* utility. Durations have no utility namespace in Tailwind v4, so they're read as a variable: duration-(--duration-slow).

Curves

Press Play to race every curve over the same distance and duration. The springs run over their settle times (see Springs), so they look like their designed durations: 400ms, and 450ms for the overshoot. The slow speed multiplies everything by four so you can read the shapes.

  • --ease-standard
  • --ease-emphasized
  • --ease-decelerate
  • --ease-accelerate
  • --ease-anticipate
  • --ease-overshoot
  • --ease-spring
  • --ease-spring-overshoot

Code

<div className="transition-transform ease-standard duration-(--duration-spring)" />
<div className="transition-transform ease-emphasized duration-(--duration-spring)" />
<div className="transition-transform ease-spring duration-(--duration-spring-settle)" />
TokenUtilityCurveUse it for
--ease-standardease-standardcubic-bezier(0.2, 0, 0, 1)Colours and fades — the default.
--ease-emphasizedease-emphasizedcubic-bezier(0.32, 0.72, 0, 1)Large travel: a tab indicator sliding across, an image growing into a lightbox.
--ease-decelerateease-deceleratecubic-bezier(0.16, 1, 0.3, 1)Transforms that enter — a popover or toast arriving. Never opacity.
--ease-accelerateease-acceleratecubic-bezier(0.4, 0, 1, 1)Exits: something leaving speeds up as it goes.
--ease-anticipateease-anticipatecubic-bezier(0.18, -0.04, 0.55, 1)Modal and drawer entrances — a hair of wind-up before they travel.
--ease-overshootease-overshootcubic-bezier(0.34, 1.56, 0.64, 1)A one-shot pop past the target and back, like a rating star being picked.
--ease-springease-springlinear(…), generatedSomething coming to rest, with no overshoot. Play it over --duration-spring-settle.
--ease-spring-overshootease-spring-overshootlinear(…), generatedA release that carries momentum past its target once. Play it over --duration-spring-overshoot-settle.

Opacity never takes --ease-decelerate

--ease-decelerate is built for things that arrive: it covers about two-thirds of the distance in the first 15% of the time, then eases into place. On a transform that reads as fast, then gentle. On opacity it reads as a blink — the element is nearly opaque almost at once, and the rest of the duration is invisible. Fade with --ease-standard, even when the transform beside it decelerates.

--ease-standard
--ease-decelerate

Code

<div className="transition-opacity ease-standard duration-[800ms]" />
<div className="transition-opacity ease-decelerate duration-[800ms]" />

Durations

TokenValueUse it for
--duration-instant100msHover and press feedback, small colour changes.
--duration-fast150msSmall surfaces appearing and leaving.
--duration-normal200msThe default: fades, toggles, most state changes.
--duration-slow300msLarge travel: a panel, a tab indicator, a morph.
--duration-spring400msHow long a spring looks — the number to design with.
--duration-spring-settle588msWhat --ease-spring actually plays over. Generated.
--duration-spring-overshoot-settle653msWhat --ease-spring-overshoot actually plays over. Generated.

Shorter is safer than longer. Exits can be a step faster than the matching entrance — by the time something is leaving, the user has already moved on.

Springs

The two spring curves aren't hand-tuned beziers: they're a damped spring, solved in closed form and sampled into a CSS linear() timing function. The kit's JavaScript plays the same springs, from the same presets, and a test fails if the CSS and the JS ever disagree.

PresetLooks likeSettles atBounceCSS tokens
settle400ms588ms0--ease-spring + --duration-spring-settle
overshoot450ms653ms0.18--ease-spring-overshoot + --duration-spring-overshoot-settle
snap250ms368ms0— (JS only)

A spring is described by how long it looks and how bouncy it is, the way Apple's Spring(duration:bounce:) and Framer's visualDuration describe it, rather than by stiffness and damping. A bounce of 0 is critically damped — the fastest approach that never overshoots — and anything above it overshoots once, then settles. A 400ms spring is 98.6% of the way there at 400ms.

The last 1.4% is still motion, though, and it takes a while: a spring creeps into place. So each spring curve has two durations. The perceived one is what you design with (--duration-spring). The settle time is what the linear() curve was sampled over, and it is the only duration that plays it correctly. Pair a spring curve with its -settle token, never with --duration-spring:

// Looks like 400ms, ends without a snap.
<div className="transition-transform ease-spring duration-(--duration-spring-settle)" />

// Wrong: squeezes the whole curve into 400ms, so it looks like ~270ms.
<div className="transition-transform ease-spring duration-(--duration-spring)" />

What CSS can't do is start a spring with momentum. When a drag is released mid-flick, the kit builds the spring with the release velocity and plays it from JavaScript, so the motion continues out of the hand instead of restarting from rest.

Reduced motion

When a visitor turns on "Reduce motion" in their OS, every animation in the kit either goes away or collapses to an instant change. State still changes — a modal still opens, a toast still leaves — only the motion between the two states is removed. The contract has three parts:

  • CSS transitions in components carry Tailwind's motion-reduce: variant (motion-reduce:transition-none, motion-reduce:animate-none).
  • Enter and exit keyframe animations (--animate-*) are collapsed to a 1ms fade by a block at the end of theme.css. It's 1ms rather than none so animationend still fires and an overlay still unmounts. A test fails if a new --animate-* token ships without its line in that block.
  • JavaScript motion checks the setting when it starts. The kit plays its own JS animations at 0ms rather than skipping them, so the last frame still lands and anything waiting on the motion to finish (moving focus, cleaning up) runs exactly as it would have.

For your own JavaScript-driven motion, use useReducedMotion:

import { useReducedMotion } from '@42-central/ui-react';

const reduced = useReducedMotion();
viewport.scrollBy({ left: delta, behavior: reduced ? 'auto' : 'smooth' });

Reading tokens from JavaScript

The Web Animations API can't take var(--ease-standard) as an easing — it wants the value. Read it off the element's computed style, which also picks up anything a consumer has retuned:

const style = getComputedStyle(el);

el.animate(keyframes, {
  duration: Number.parseFloat(style.getPropertyValue('--duration-slow')),
  easing: style.getPropertyValue('--ease-emphasized'),
});

This is what the kit does internally, with the token values built in as a fallback for when theme.css isn't loaded.

Retuning

The tokens are ordinary custom properties on :root. Override them there and every transition that uses them follows — the kit's and yours:

:root {
  --duration-slow: 250ms;
  --ease-emphasized: cubic-bezier(0.3, 0.7, 0, 1);
}

Don't hand-edit the two linear() spring tokens or their -settle durations; they're generated in pairs. If you replace a spring curve with your own linear(), replace its -settle duration with it.

Changelog

v0.20.0
  • Motion tokens: ease-standard, ease-emphasized, ease-decelerate, ease-accelerate, ease-anticipate, ease-overshoot, ease-spring and ease-spring-overshoot, plus --duration-instant to --duration-spring, each spring with a --duration-spring-settle

    #342

On this page