Motion system
Roles, not magic numbers.
Components never write a raw duration or easing. They ask for a role (micro, base, layout or emphasis) and the active personality decides what that means.
Compare personalities
The same component, rendered under each personality at once.
Elasticity
Each personality sets how rubbery things feel: the elastic spring, how much shapes squash and stretch at speed, and how far a drag follows past its limits. Drag a ball past the edge and let go.
Precise
stretch 0band 0.05
Smooth
stretch 0.05band 0.15
Playful
stretch 0.14band 0.35
Cinematic
stretch 0.04band 0.12
Elastic
stretch 0.22band 0.55
Roles
micro
Icon swaps, toggles, presses, chevrons
base
Entrances and exits: messages, chips, toasts
layout
Height and position: accordions, sliding pills, stacks
emphasis
Moments that deserve attention: success, numbers, hero
elastic
Rubbery overshoot: drags, switches, cursors, playful reveals
Personality tokens
Springs are listed as visual duration · bounce.
| Token | Precise | Smooth | Playful | Cinematic | Elastic |
|---|---|---|---|---|---|
| ease.out | [0.2, 0, 0, 1] | [0.16, 1, 0.3, 1] | [0.34, 1.56, 0.64, 1] | [0.22, 1, 0.36, 1] | [0.34, 1.8, 0.64, 1] |
| duration.base | 160ms | 200ms | 220ms | 260ms | 240ms |
| spring.micro | 0.15s · 0 | 0.2s · 0.1 | 0.22s · 0.45 | 0.22s · 0 | 0.24s · 0.55 |
| spring.base | 0.22s · 0 | 0.26s · 0 | 0.28s · 0.35 | 0.3s · 0 | 0.3s · 0.5 |
| spring.layout | 0.26s · 0 | 0.28s · 0.05 | 0.3s · 0.3 | 0.32s · 0.05 | 0.32s · 0.45 |
| spring.emphasis | 0.3s · 0.05 | 0.32s · 0.15 | 0.34s · 0.5 | 0.35s · 0.1 | 0.35s · 0.65 |
| distance.md | 4px | 8px | 14px | 20px | 14px |
| blur | 0px | 4px | 2px | 12px | 0px |
| scaleFrom | 0.97 | 0.94 | 0.6 | 0.9 | 0.5 |
| pressScale | 0.97 | 0.95 | 0.88 | 0.97 | 0.9 |
| stagger | 25ms | 50ms | 70ms | 100ms | 60ms |
| spring.elastic | 0.3s · 0.15 | 0.32s · 0.35 | 0.34s · 0.55 | 0.35s · 0.3 | 0.35s · 0.75 |
| stretch | 0 | 0.05 | 0.14 | 0.04 | 0.22 |
| rubberBand | 0.05 | 0.15 | 0.35 | 0.12 | 0.55 |
The personality is also written to CSS variables (--motion-ease-out, --motion-duration-base, …), so CSS transitions like transition-ui follow it too.
Use it in a component
One hook gives you springs, tweens and presets for the active personality.
"use client";
import { motion } from "motion/react";
import { useMotion } from "@/lib/motion";
export function Badge({ children }: { children: React.ReactNode }) {
const m = useMotion();
return (
<motion.span
{...m.pop()} // preset: scale + blur in, using the personality
whileTap={m.press} // personality's press scale
className="rounded-chip bg-chip px-3 text-sm text-chip-fg shadow-bevel"
>
{children}
</motion.span>
);
}
// Other helpers:
// m.spring("micro" | "base" | "layout" | "emphasis")
// m.tween("fast" | "base" | "slow" | "slower", "out" | "inOut" | "in")
// m.fadeUp(), m.swap(), m.collapse(), m.stagger(i), m.distance.md, m.blur()
// m.drag() rubber-band drag that springs home
// useStretch(x, y) squash & stretch from velocity
// className="transition-elastic" the elastic spring in plain CSSAdd your own personality
Add an entry and it appears in every switcher automatically.
// lib/motion.tsx — add a key to `personalities`
export const personalities = {
// …precise, smooth, playful, cinematic, elastic
brand: {
label: "Brand",
description: "Our house style.",
ease: { out: [0.25, 1, 0.5, 1], inOut: [0.65, 0, 0.35, 1], in: [0.5, 0, 0.75, 0] },
duration: { fast: 0.12, base: 0.2, slow: 0.32, slower: 0.5 },
spring: {
micro: { visualDuration: 0.2, bounce: 0.15 },
base: { visualDuration: 0.3, bounce: 0.1 },
layout: { visualDuration: 0.35, bounce: 0.1 },
emphasis: { visualDuration: 0.45, bounce: 0.25 },
elastic: { visualDuration: 0.5, bounce: 0.45 },
},
distance: { sm: 3, md: 6, lg: 12 },
blur: 3,
scaleFrom: 0.92,
pressScale: 0.95,
stagger: 0.04,
stretch: 0.08,
rubberBand: 0.2,
},
} satisfies Record<string, MotionPersonality>;