Repository navigation
Closed
Labels
designVisual design decisions and questionsenhancementNew feature or requestthemingTheming system, design tokens, createTheme
Description
Summary
This proposal outlines a motion token system for XDS, organized into three layers: duration, easing, and composites. This document covers the naming approaches evaluated and the rationale for the layered architecture landed on.
Naming Schemes Considered
1. Flat Semantic Tokens (e.g. --motion-enter, --motion-slide-in)
Pros:
- Simple to consume, one token per use case
- Abstracts away implementation details (builders don't need to think about curves or timing)
- Easy to enforce consistency since there are fewer knobs to turn
Cons:
- Without primitive layers underneath, it may lead to many combinations. Every new interaction pattern (enter, exit, slide, expand, collapse, fade, etc.) needs its own token. A layered approach helps with this by letting builders compose from primitives directly when no composite token exists.
- Hard to extend without breaking the naming convention.
2. Physics-Based Tokens (e.g. springs)
Pros:
- Feels most natural visually
- Can accommodate some very complex animations
Cons:
- Springs are JavaScript-exclusive. They require a JS animation runtime and cannot be expressed as CSS custom properties, making them a poor fit for a token-based system and significantly harder to theme.
- The CSS
linear()function can approximate spring curves by baking them into a series of stops, but the resulting values are verbose and difficult to customize or hand-tune compared to a simplecubic-bezier()with four control points. - Harder to adopt for builders unfamiliar with spring dynamics
3. Scale-Based Naming (e.g. --duration-100, --duration-200, etc.)
Pros:
- Zero ambiguity, you know exactly what you're getting
- Easy to reason about relationships (300 is between 200 and 400)
- Simple to add new values without renaming everything (just add
--duration-275)
Cons:
- If you ever want to globally shift your timing scale (say, make everything 20% faster), you'd have to update every value and every reference, or live with misleading names (
--duration-300: 240ms). - Loses the "why". Seeing
--duration-300on a component doesn't tell you how it's being used (e.g. micro-interaction or a layout shift).
4. Layered Primitives + Composites (proposed approach)
Pros:
- Separation of concerns: duration and easing are independent axes that can be mixed and matched
- Composites provide guardrails: semantic composite tokens (
--motion-enter,--motion-exit) give builders the easy path while the primitives remain accessible for edge cases - Extensible: adding a new easing curve doesn't require touching duration tokens, and vice versa
- Readable:
var(--duration-medium) var(--easing-decelerate)is self-documenting in a way thatvar(--motion-200)is not - Range support: duration tokens can express a range (
fast-min,fast,fast-max) giving designers flexibility within a bounded corridor
Cons:
- Slightly more complex than a flat system. Builders need to understand the layering to customize.
- Composite tokens need to be curated to avoid becoming too large to manage easily.
- The
min/maxrange convention for durations is non-standard and needs documentation (based on XMDS)
Proposed Token Structure
:root {
/* Layer 1: Duration primitives */
--duration-fast-min: 130ms;
--duration-fast: 175ms;
--duration-fast-max: 230ms;
--duration-medium-min: 310ms;
--duration-medium: 410ms;
--duration-medium-max: 550ms;
/* Layer 2: Easing primitives */
--easing-decelerate: cubic-bezier(0.24, 1, 0.4, 1);
/* Layer 3: Semantic composites */
--motion-enter: var(--duration-medium-max) var(--easing-decelerate);
--motion-exit: var(--duration-medium-min) var(--easing-decelerate);
--motion-slide-in: var(--duration-medium) var(--easing-decelerate);
--motion-slide-out: var(--duration-medium-min) var(--easing-decelerate);
}Why This Approach
Duration and easing are distinct concerns. By keeping primitives separate and composing them into semantic tokens at a higher layer, we get:
- A small token surface: a handful of durations x a handful of easings covers a wide range of use cases
- Composites as the happy path: most builders should reach for
--motion-enterand never think about the layers beneath - Primitives as an escape hatch: when a component needs a non-standard combination, it can compose from primitives rather than requesting a new one-off token
- Clear mental model: "pick your duration, pick your easing, or use a preset" is easy to teach
- Avoids explosion of combinations: composite tokens only need to cover the most common patterns. When a component needs a non-standard combination, builders compose directly from primitives (
var(--duration-fast) var(--easing-decelerate)) rather than requesting a new semantic token. The primitives handle the long tail.
Questions to answer
- What additional primitives and composites are needed?
- How should reduced-motion preferences interact with these tokens? (e.g.
--duration-fast: 0msunderprefers-reduced-motion?) - Should composites include transition-property or stay limited to duration/easing values? Under the current proposal builders still have to specify what is being transitioned, like opacity, transforms, etc.
Metadata
Metadata
Assignees
Labels
designVisual design decisions and questionsenhancementNew feature or requestthemingTheming system, design tokens, createTheme
Activity
tedmcdo commentedon Mar 18, 2026
Will upload a prototype (3/18) using this token structure to demonstrate navigational changes.
rubyycheung commentedon Mar 18, 2026
@tedmcdo can you add a compute formula and another example for comparision?
rubyycheung commentedon Mar 18, 2026
Cindy: Hardcode for now to help with exploration and decision-making
tedmcdo commentedon Mar 18, 2026
Durations are decreasing values by 25% from 550. Then the numbers get rounded to cleaner numbers. This was meant to align with typical ranges for enter/exit ratios: exits should generally be 60-75% the speed of entrances.
cixzhang commentedon Mar 18, 2026
Motion Token Analysis & Vibe Test Results
Hey Ted! We did a deep audit of existing animations in XDS and ran a vibe test on the proposed token architecture. Here's everything.
Audit: Current Animation Surface
XDS currently has 2 motion tokens in
tokens.stylex.ts:These bundle duration + easing into one shorthand, which is technically invalid when used as
transitionDuration(theeaseleaks in). The new system fixes this by separating concerns.30 components use these tokens (Button, Calendar, Checkbox, Switch, Tab, etc.) — all mechanical find-and-replace migrations. 6 components bypass the tokens entirely with hardcoded values — these are the highest-priority targets:
0.25s cubic-bezier(0.4, 0, 0.2, 1)--motion-slide-in/--motion-slide-out150ms ease--duration-fast+--easing-decelerate0.15s ease--duration-fast+--easing-decelerate0.15s ease--duration-fast+--easing-decelerate0.1s ease--duration-fast-min+--easing-decelerate0.2s ease-out--motion-enter4 looping animations (Spinner, Skeleton, StatusDot, ProgressBar indeterminate) don't fit the enter/exit model — recommend leaving as-is.
Vibe Test: Do LLMs Use min/max Variants?
We ran a structured vibe test — 10 prompts × 2 configs (with and without min/max range tokens), 20 sub-agent runs total.
Result: LLMs absolutely reach for min/max variants, and they produce better motion design when they have them.
--duration-medium-minwas the most popular (5 uses) — naturally chosen for dropdowns, popovers, accordion collapses, and exit animationsWhere range tokens made the biggest difference
Asymmetric timing — when prompts asked for "snappier close" or "faster collapse":
Without range tokens, the agent is forced into jarring ratios because there's no middle ground between
fastandmedium.Element-size differentiation:
medium-max(550ms)medium(410ms)medium-min(310ms)medium(410ms)fast-min(130ms)fast(175ms)With only 2 durations, a small popover and a full dialog get the same timing.
One caveat: The LLM treats the "Use when..." descriptions as gospel. Having "tooltip fades" listed under
--duration-medium-min(310ms) led the agent to pick 310ms for tooltips — but XDS currently uses 100ms. The documentation descriptions need careful curation.Answers to Open Questions
1.
prefers-reduced-motion: We'd handle this at the consumption site, not in the tokens. The tokens always represent designed intent; a global rule (@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; } }) disables animation system-wide. This matches existing behavior in MobileNav/StatusDot and ensures nothing slips through.2. Should composites include
transition-property? Recommend no — keep them limited to duration/easing. Builders should still specify what's being transitioned. This keeps the composites simple and avoids encoding layout assumptions.3. What additional primitives/composites? Based on the audit:
--easing-standard: cubic-bezier(0.4, 0, 0.2, 1)— MobileNav already uses this, and the vibe test agents naturally chose it for symmetric transitions (hover, toggle states)--easing-acceleratefor exit-only animations (nothing uses it today, but it completes the set)Idea: Computed Duration Scale
Rather than defining all 6 duration values manually, we could derive min/max from base values + a ratio in the theme config — as a dedicated
motionScalekey, similar to how type scales work:This means theme authors only configure 3 values (fast, medium, ratio) and get a coherent 6-token scale. A "snappy" theme sets a lower base; a "cinematic" theme raises the base — and the proportional relationships are preserved automatically.
Summary
motionScaleconfig— via Navi on behalf of @Cindyxz
feat(theme): motion token primitives — duration, easing, and componen…
feat(theme): motionScale config for defineTheme — computed duration s…
feat(theme): motionScale config for defineTheme — computed duration s…
feat(theme): motionScale config for defineTheme — computed duration s…
feat(theme): motionScale config for defineTheme — computed duration s…
feat(theme): motion token primitives — duration, easing, and componen…
feat(theme): motionScale config for defineTheme — computed duration s…
feat(theme): motion token primitives — duration, easing, and componen…
feat(theme): motionScale config for defineTheme — computed duration s…
feat(theme): motion token primitives — duration, easing, and componen…
feat(theme): motionScale config for defineTheme — computed duration s…