Motion Rules

Twenty exact rules for interface motion: ease-out entrances, 0.97 presses, 30ms staggers, popovers from the trigger, exits 20% shorter, masks, icon crossfades, rubber bands and shared layoutIds.

Skills

Inspired by baseline-ui by ibelick, the UI Skills playbook by ui-skills.com, animate by Emil Kowalski, awwwards-motion-study by INSANE0777 and better-ui by Jakub Krehel.

Showcase

Twenty rules, each with an exact value, and a frame that runs every one of them. Pick a rule below and the parts that show it light up. Switch Motion to Slow-mo to watch the curves frame by frame.

The twenty

Showcase

Balance

$1,200.35

Payment
$30.32
Due
Aug 9th
OpenRundeRegularMediumHeavy

Overview

Seats
2

$20/ month

Billed monthly

Activity
  • MMaya commented on Overview
  • LLeo invited you to Team
  • AAna shipped Settings v2

Files it creates

lib/motion.ts
import type { Transition } from "motion/react";

// Curves. Built-in CSS easings are too weak for UI.
export const EASE_OUT = [0.23, 1, 0.32, 1] as const; // 1. entrances and exits
export const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const; // 9. on-screen moves

// Durations, in seconds.
export const DURATION = {
press: 0.15, // 4.
dropdown: 0.2, // 2. 150-250ms
popover: 0.2,
dialog: 0.25,
move: 0.35, // 9.
pulse: 0.6, // 8.
} as const;

// 15. Exits are 20% shorter than their entrance.
export const exit = (enter: number) => enter * 0.8;

// 3. and 6.
export const STAGGER = { rows: 0.03, details: 0.06, cap: 10 } as const;

export const PRESS_SCALE = 0.97; // 4.
export const POPOVER_FROM = 0.95; // 10.
export const KNOB_STRETCH = 1.12; // 5.

// 13. Everyday UI never bounces.
export const SPRING: Transition = { type: "spring", duration: 0.3, bounce: 0 };

// 18. Contextual icon swap.
export const ICON_SWAP = {
initial: { opacity: 0, scale: 0.25, filter: "blur(4px)" },
animate: { opacity: 1, scale: 1, filter: "blur(0px)" },
exit: { opacity: 0, scale: 0.25, filter: "blur(4px)" },
transition: SPRING,
} as const;

// 19. Apple's rubber band: resistance grows the further past the edge.
export function rubberband(overshoot: number, limit: number, c = 0.55) {
const sign = Math.sign(overshoot);
const x = Math.abs(overshoot);
return sign * limit * (1 - 1 / ((x * c) / limit + 1));
}

// 19. Clamp a value into [min, max], rubber-banding whatever falls outside.
export function rubberClamp(value: number, min: number, max: number, limit = 48) {
if (value < min) return min + rubberband(value - min, limit);
if (value > max) return max + rubberband(value - max, limit);
return value;
}

Credits

This skill stands on these. Where they disagree it picks one and says so: press scale is 0.97 here (better-ui and the playbook use 0.96), and exits are a ratio of their entrance rather than a fixed time.

  • by ibelick

    Compositor-only properties, ease-out entrances, the 200ms feedback ceiling.

    npx skills add https://github.com/ibelick/ui-skills --skill baseline-ui
  • by ui-skills.com

    Faster follow-up tooltips, blurred label swaps, solid scrims over blurred backdrops, instant repeats.

    https://www.ui-skills.com/playbook
  • by Emil Kowalski

    The frequency gate, the curves, the duration table, origin at the trigger.

    npx skills add https://github.com/emilkowalski/skills --skill animate
  • by INSANE0777

    Studying motion frame by frame, and writing stagger and overlap down as numbers.

    npx skills add https://github.com/INSANE0777/awwwards-skills --skill awwwards-motion-study
  • by Jakub Krehel

    Exact values over ranges, icon crossfades with blur, shorter exits, initial={false}.

    npx skills add https://github.com/jakubkrehel/skills --skill better-ui