Core motion contract
Use this skill for the repository's operative motion rules. For animation
craft (timing, easing, choreography, when not to animate), load
docs/ai/skills/emil-design-engineering/SKILL.md first. For motion/react
API details, use the motion skill.
Workflow
- Decide what the motion communicates (feedback, hierarchy, spatial continuity). If it is decoration, leave it out.
- Use the shared tokens, utilities, and presets below instead of raw durations, curves, or scales.
- Animate
transformandopacity; entrances ease out, exits ease in and run faster than entrances. - Define reduced-motion behavior and check the route view-transition rules when the element sits inside an app shell.
- Run
node scripts/check-motion-patterns.mjs <files>on changed files;tests/unit/motion-contract.test.tsguards the banned class patterns.
Two synchronized halves
- CSS tokens in
packages/ui/styles/globals.css(:root) — the baseline for Tailwind, Base UI surfaces, and global CSS. - TS constants in
packages/lib/motion-presets.ts(@asym/lib/motion-presets) — the pair formotion/reactand shared helpers. Prefer these over raw literals.
When updating one half, update the other.
CSS tokens (`packages/ui/styles/globals.css :root`)
/* Easing */
--ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
--ease-in-soft: cubic-bezier(0.4, 0, 1, 1);
--ease-in-out-soft: cubic-bezier(0.77, 0, 0.175, 1);
--ease-drawer: cubic-bezier(0.32, 0.72, 0, 1); /* iOS curve */
/* Duration tiers — product UI stays under 300ms unless ceremonial */
--duration-press: 120ms; /* button/tile press feedback */
--duration-micro: 150ms; /* hover, color change */
--duration-standard: 220ms; /* tooltip, popover, dropdown, select */
--duration-modal: 220ms; /* dialog open/close */
--duration-drawer: 320ms; /* sheet / vaul drawer */
--duration-route: 240ms; /* matches asym-vt-route-* */
--duration-shared: 280ms; /* matches asym-vt-share-* */
/* Stagger */
--stagger-tight: 45ms;
--stagger-medium: 60ms;
/* Transform — never below 0.95 */
--scale-press: 0.98;
--scale-hover-subtle: 1.02;
--scale-entrance: 0.96;
The values in globals.css are authoritative; keep this copy in sync when tokens change.
CSS utilities (same file)
| Utility | What it does | Touch-safe? | Pair with |
| --------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------- | --------------------------------- |
| .press-feedback | :active scale to var(--scale-press) | Yes (:active fires on tap) | Already on every <Button> |
| .hover-lift | :hover translateY(-2px) | Yes (@media (hover: hover) and (pointer: fine)) | Cards, tiles, list rows |
| .hover-scale-subtle | :hover scale(var(--scale-hover-subtle)) | Yes (@media (hover: hover) and (pointer: fine)) | Buttons, badges, marketing CTAs |
| .spinner-essential | infinite spin exempt from the reduced-motion kill (essential status feedback) | Yes | Loader2 loading indicators only |
The first three share one transition-property declaration, so they can be stacked on one element without overriding each other's transition list.
TS constants (`@asym/lib/motion-presets`)
EASE_OUT_SOFT, EASE_IN_SOFT, EASE_IN_OUT_SOFT, EASE_DRAWER, DURATION_PRESS, DURATION_MICRO, DURATION_STANDARD, DURATION_ROUTE, DURATION_SHARED, DURATION_DRAWER, DURATION_SLOW, STAGGER_TIGHT, STAGGER_MEDIUM, SCALE_HOVER_SUBTLE, SCALE_TAP_SUBTLE, SCALE_ENTRANCE. They match the CSS tokens in numeric intent, not always in name (DURATION_SLOW is a TS-only marketing/hero tier; SCALE_TAP_SUBTLE matches --scale-press).
Pre-built Transition objects: transitionStandard, transitionSlow, transitionExitQuick, springTap (gestures only).
Reduced-motion-aware helpers:
propsHeroEntrance(reduceMotion, delay?, y?)— fade + small rise.propsFadeRiseInView(reduceMotion, options?)— fade + rise on scroll-in.propsScaleFadeInView(reduceMotion, options?)— fade + scale fromSCALE_ENTRANCE.
`@asym/lib/motion` and `@asym/lib/motion-provider`
ESLint (tooling/eslint-config/restricted-imports.mjs) bans importing motion/react or framer-motion directly. Import from @asym/lib/motion, which exports motion (the lazy m component), AnimatePresence, LayoutGroup, LazyMotion, domAnimation, useInView, useReducedMotion, and the common types.
Because motion is the lazy m component, it needs the MotionProvider from @asym/lib/motion-provider above it (LazyMotion features={domAnimation} plus MotionConfig reducedMotion="user"). Each app's root layout.tsx already mounts it.
Repo motion standard (operative rules)
packages/ui/styles/globals.css and packages/lib/motion-presets.ts are the runtime contract. This file and the Motion section of docs/ai/rules/frontend.md describe how to apply it; keep them in sync when policy changes.
When not to animate
- Anything triggered by
⌘K,⌘B, or other keyboard shortcuts. The command palette is intentionally instant (packages/ui/components/shadcn/command.tsx). - Form validation errors. Use color, icon, and text for visual feedback; errors must still be named, associated, and exposed programmatically.
- Live data, timers, ticker counters —
tabular-nums, no animation. - Sortable or filtered list reordering at high frequency — no per-row springs or per-row
layout(packages/missionary/components/tasks/task-row.tsx). - Disabled controls — no hover or press feedback (
Buttonappliesdisabled:pointer-events-none disabled:opacity-50).
Hover on touch
- Any
hover:scale-*,hover:-translate-*, orhover:shadow-*lift must be wrapped in@media (hover: hover) and (pointer: fine);scripts/check-motion-patterns.mjsflags ungatedhover:scale-*. - Prefer
.hover-liftor.hover-scale-subtle(both gated). Forgroup-hover:patterns, use the arbitrary variant[@media(hover:hover)_and_(pointer:fine)]:group-hover:scale-[var(--scale-hover-subtle)].
Transitions and press feedback
- Never use
transition-all; list properties (transition-colors,transition-[transform,box-shadow]). Button(packages/ui/components/shadcn/button-variants.ts) includes.press-feedbackin its base andhover-scale-subtleon themaiavariants. Native<button>elements that do not useButtonadd.press-feedbackdirectly.- Never add
active:scale-*inline; it duplicates the contract. - Do not animate layout properties (height, width, margins, padding, offsets) in
motion/reactprops; the motion guard flags them.
Popover, tooltip, and dropdown origin
- Base UI popup surfaces use
transform-origin: var(--transform-origin)(origin-(--transform-origin)in Tailwind). Shared primitives already do this. - Modals (
Dialog, full-screen overlays) keeptransform-origin: center.
Route transitions
RouteMainViewTransitionBoundary(@asym/ui/components/view-transitions) owns route transitions. It wraps the content region of each app shell:apps/admin/app/mc-shell.tsx,apps/donor/app/(dashboard)/donor-dashboard/layout.tsx, andapps/missionary/components/app-shell.tsx.- It is a no-op unless
NEXT_PUBLIC_VIEW_TRANSITIONS_ENABLED=true, the browser supports view transitions, and reduced motion is off. - Its
<ViewTransition>is keyed by pathname, because a persistent layout never remounts on its own. When enabled, the route-content subtree remounts on every navigation (template.tsxsemantics: client state below the shell resets). - Page bodies inside the boundary get no unconditional entrance: gate CSS
animate-inclasses andmotioninitialprops withuseWithinViewTransitionRouteLayer()from@asym/lib/view-transitions.packages/ui/components/primitives/page-shell.tsxis the template (!withinRouteVt && "motion-safe:animate-in ..."). - For an
AnimatePresencelist inside the boundary, gate only the first mount with<AnimatePresence initial={!withinRouteVt}>; a per-iteminitialternary would also remove the add/remove animation. - View-transition CSS in
globals.cssmust use the class selector form::view-transition-old(.asym-vt-route-exit)(leading dot). React appliesenter/exit/sharevalues asview-transition-class; an undotted ident targets a view-transition name and matches nothing (guarded bytests/unit/motion-contract.test.ts). - Do not add
motion.div layouton the swapping region.
CSS transitions, tweens, and springs
- CSS transitions for state changes (open/close, hover, press, color).
motion/reacttweens for orchestrated entrances and exits (page mounts, hero strips, lists).- Springs only for gestures and decorative interactions — not for stat cards, list rows, or buttons.
Tooltip timing
- The shared
TooltipProvider(packages/ui/components/shadcn/tooltip.tsx) defaults todelay={300}and keeps Base UI's defaulttimeout(400ms), the window in which moving between grouped triggers skips the open delay. - The admin, donor, and missionary root layouts wrap the app in
<TooltipProvider delay={0}>, and the rich-text toolbar sets its owndelay={0}. Change these deliberately; do not infer instant behavior fromtimeout.
Reduced motion
- The repo-wide
prefers-reduced-motion: reducebaseline lives only inpackages/ui/styles/globals.css, which also zeroes view transitions. Apps must not redeclare it. MotionProvidersetsMotionConfig reducedMotion="user", which disables transform and layout animations for everymotioncomponent.- New or refactored
motion/reactcode that needs more than that usesuseReducedMotion()and returnstransition: { duration: 0 },initial: false, or skips motion. Examples:packages/ui/components/primitives/motion-preset.tsx,packages/ui/components/primitives/ripple-button.tsx,packages/missionary/components/tasks/task-row.tsx,packages/missionary/components/tasks/task-stats.tsx.
Repo examples
- Entrance gated by the route layer:
packages/ui/components/primitives/page-shell.tsx(tokens,motion-safe, view-transition awareness). - Button:
packages/ui/components/shadcn/button-variants.ts(press-feedbackon the base,hover-scale-subtleformaiavariants, notransition-all). - List row:
packages/missionary/components/tasks/task-row.tsx(one stagger entrance, no per-rowlayout, no per-element springs,hover-lift).
Checklist
- [ ] Shared tokens, utilities, or presets used instead of raw literals.
- [ ] Mostly
transformandopacity; no layout-property animation. - [ ] No
transition-all, inlineactive:scale-*, or ungated hover lift. - [ ]
motion/reactAPIs imported from@asym/lib/motion. - [ ] Entrances inside the route boundary gated with
useWithinViewTransitionRouteLayer(). - [ ] Reduced-motion behavior defined; no app-level redeclaration of the baseline.
- [ ]
node scripts/check-motion-patterns.mjs <files>passes for changed files.