Repository navigation
feat(motion): adopt spring tokens and add shared CSS-transition helper - #5112
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It changes core animation mechanics (tokenized CSS transitions + spring adoption) across widely used components like TextInput, which is cross-platform sensitive and should get final human verification.
Pull request overview
This PR continues the MD3 Expressive motion modernization by (1) introducing a shared helper for Reanimated CSS-transition styles derived from theme motion tokens, and (2) migrating/deduping several components to use those tokens and the CSS-transition tier consistently (including adopting a spring token for SegmentedButtonItem).
Changes:
- Added
getTransition(...)insrc/theme/tokens/sys/motion.tsand unit tests validating token lookup + reduce-motion behavior. - Refactored
TextInputlabel/indicator animations from imperative Reanimated timing/shared-values to render-driven CSS transitions, and added regression tests asserting the computed label styles across focus/blur. - Updated
BadgeandCheckboxto use the shared transition helper; updatedSegmentedButtonItemto use a theme spring token viatoRawSpring(...).
File summaries
| File | Description |
|---|---|
| src/theme/tokens/sys/motion.ts | Adds getTransition helper to standardize CSS transition duration/easing/property from motion tokens. |
| src/theme/tests/motion.test.ts | Adds unit coverage for getTransition token lookup, reduce-motion, and easing construction. |
| src/components/TextInput/TextInput.tsx | Removes now-unused animation handler types; consumes updated hook-driven animation state. |
| src/components/TextInput/hooks.ts | Replaces imperative label/indicator animation with boolean-state-driven CSS transition styles; wires reduce-motion via context. |
| src/components/TextInput/constants.ts | Removes timing/easing constants tied to imperative withTiming animation. |
| src/components/SegmentedButtons/SegmentedButtonItem.tsx | Replaces hardcoded spring config with theme spring token via toRawSpring. |
| src/components/Checkbox/Checkbox.tsx | Dedupes CSS transition props through getTransition. |
| src/components/Badge.tsx | Switches Badge opacity transition to tokenized getTransition + useReduceMotion. |
| src/components/tests/TextInput.test.tsx | Adds assertions for label wrapper/text styles across focus/blur in filled + outlined variants. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🔵 Needs a closer look
It changes animation mechanisms and motion-token wiring in core components (notably TextInput), where subtle platform/runtime differences are hard to fully validate from diff review alone.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/components/tests/TextInput.test.tsx:83
getLabelWrappercurrently returns the first node witharia-hidden === true, butTextInputcan render multiplearia-hiddenelements (e.g. the error icon wrapper). That makes this helper non-specific and can cause future tests to assert styles on the wrong element if anotheraria-hiddennode appears earlier in the tree.
Consider narrowing the predicate to only match the label wrapper by additionally requiring a transition style marker (e.g. transitionProperty in the style object/array), which should be unique to the animated label wrapper in these tests.
- Files reviewed: 9/9 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
The helper’s default generic currently permits invalid transition-property names.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/theme/tokens/sys/motion.ts:142
- The
Record<string, unknown>default erasestransitionPropertyvalidation because its keys accept any string, so typos such as'opactiy'compile and produce a no-op/invalid transition at runtime. Use Reanimated's own defaultCSSTransitionPropertiesstyle type here so callers are constrained to supported style keys.
- Files reviewed: 9/9 changed files
- Comments generated: 0 new
- Review effort level: Balanced
JKobrynski
left a comment
There was a problem hiding this comment.
Just one thing from me
|
Found potential problems with the pull request:
|
There was a problem hiding this comment.
🟡 Changes recommended
The opacity-only reduced-motion exemption is ineffective because PaperProvider still forces animation.scale to zero, causing transitions to snap; the provider override must be separated from the user-controlled multiplier and covered by a provider-backed regression test.
1 open issue
1 resolved since last review
Review effort: Balanced
6c5697b to
2005351
Compare
|
/review |
There was a problem hiding this comment.
🔵 Needs a closer look
The TextInput transitions and affix animations need visual confirmation on iOS, Android, and web, including interrupted focus/blur, since Jest checks only target styles and no before/after comparisons were available.
2 open issues
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on c5b4cf9. The verdict and the full list are in the summary comment.
There was a problem hiding this comment.
🔵 Needs a closer look
JavaScript-timed TextInput transitions still require human native/web visual checks for interrupted focus/blur and placeholder/affix timing, since platform execution and linked-media inspection were unavailable.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Two active issues remain: synchronous clearing can leave an empty input’s label floated after blur, and adding a start accessory can cause an outlined label to jump horizontally before animating back.
2 open issues
Review effort: Balanced
Review:
|
| Platform | Result | How it was checked |
|---|---|---|
Static (tsc, eslint, jest) |
✅ | tsc clean outside docs/, eslint clean on touched files, jest 1581 passed |
| iOS | ✅ | iPhone 17 Pro simulator, dev client |
| Web | ✅ | Expo web, computed styles sampled during transitions |
| Android | ✅ | Pixel 4 API 34 emulator, dev client |
Suggestions (non-blocking)
isLabelFloatedtimer. It flips on asetTimeoutofshort3ms, because CSS transitions report no end. On a busy JS thread the placeholder can show late, and with reduce motion it flips one tick after the label jumps. A short comment next to the timer would help.- Changelog / migration note. These changes are user-visible, but the diff only touches code comments and
code.instructions.md:- TextInput now follows
<PaperProvider reduceMotion>instead of the OS setting. clear()no longer drives the blur animation.- Label position changes from layout (accessory, RTL) now animate.
- Badge easing is now
standard. - The SegmentedButtons check overshoots differently per theme.
- TextInput now follows
- Affix fade-in test. The logic is subtle: state is set during render, and a CSS animation is used because a transition doesn't run on mount. Affixes present on the first render intentionally don't fade. A test for first mount vs. re-float would protect it, if there isn't one already.
- "Dense" in the PR description. I couldn't find a dense path in the TextInput label layout (
getTextInputAnimationLayoutonly takesvariant,hasAccessoryandisRTL). Either the description is out of date or I'm missing a case.
Static checks
tscis clean outsidedocs/.- eslint is clean on the touched files.
- jest: 1581 passed. 4 snapshot tests failed only because I ran from a different directory (
ListImageandAppbarembed asset paths), so I don't think they're related to this PR.
iOS (iPhone 17 Pro simulator)
- TextInput:
- Focus floats the label and fills the underline, and the placeholder shows.
- Typing with a prefix keeps the label floated.
clear()while focused keeps the label floated.- Blur on an empty field drops the label and removes the prefix.
- RTL with a start accessory positions both the floated and resting label correctly.
- Badge: fades out and back in.
- Checkbox: toggles work, and the parent follows its children.
- SegmentedButtons: the check moves to the newly selected segment.
reduceMotion="on": TextInput ends in the correct states with no errors.
Web (Expo web)
I checked computed styles and sampled them during the transitions.
- TextInput:
- The label wrapper animates
top20→8px, and the labelfont-sizegoes 16→12px. - Both use
0.15s cubic-bezier(0.2, 0, 0, 1), i.e.short3with thestandardeasing. - The filled-variant underline animates its
transform(scaleX). - Clearing a blurred, non-empty field sends the label back to rest.
- The label wrapper animates
- Badge: opacity goes 1→0 over about 150 ms with the
standardcurve (the intended easing change). - Checkbox:
- Fill, outline and state layer fade over 0.1s.
- The check mask animates
width, opacityover 0.15s. - The curves are unchanged by the dedup.
- SegmentedButtons: the check scale goes 0 → 1.067 → 0.995 → 1.0, the expected
fast.spatialovershoot in the expressive theme. reduceMotion="on": Badge, TextInput label and wrapper showtransition-duration: 0s, and states jump to their end values.- The console is clean.
Android (Pixel 4 API 34 emulator)
- TextInput: focus, type, blur with text, and clearing a blurred field all behave correctly. The prefix and clear action work.
- RTL: the label floats next to the leading icon and rests beside it.
- Badge, Checkbox (including parent/children) and SegmentedButtons: all behave correctly.
- OS "remove animations" set to 0: TextInput still ends in the correct states, with no crashes and no PR-related errors.
Not covered
- Web in LTR (the example opened in RTL), and browsers other than the one I used.
- Frame-by-frame motion on iOS and Android. My screenshots only showed end states, so please check the spring overshoot and transition feel on a device.
reduceMotion="auto"actually picking up the OS setting on Android.
Unrelated noise I saw (not from this PR)
- Reanimated "Dependencies should only be used on the web" warnings in Metro. I found no Reanimated hooks with dependency arrays in
src. - On iOS, "999+" in the Badge example clips to "99…" because of the badge's existing
maxWidth. - An
ExpoKeepAwake.deactivateerror toast on Android relaunch, which comes from the dev client.
- Always update `hasValue` in `onChangeText`, so a nested clear from the parent's handler drops the label on blur. - Transition the outlined label inset with its translateX, so adding a start accessory to a floated label no longer makes it jump. On web the inset uses `left`/`right`, which a CSS transition can target. - Document the `isLabelFloated` timer caveats. - Test the affix fade-in on re-float vs. first render. - Drop the stale note that TextInput ignores the `reduceMotion` prop.
|
Thanks for the thorough review! Addressed in 3c243d6:
|
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because the published review omits moderate findings affecting web reduced-motion behavior and outlined-label positioning during direction changes.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
|
/review |
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
The chevron's CSS transition keeps its duration, easing and reduce motion handling, now built with the getTransition helper that Badge, Checkbox and TextInput use since callstack#5112.


Motivation
MD3 Expressive replaces easing+duration with springs where motion is spring-shaped; CSS transitions are the default otherwise. #5015 handled the library swap + CSS-transition conversion; this PR adds spring adoption + a shared
getTransitionhelper.getTransition()CSS-transition helper intheme/tokens/sys/motion.tsBadge: uses helper; easing nowstandard(duration and reduce motion unchanged)Checkbox: deduped onto helper, no behavior changeTextInput: label float/active-border now CSS transitions; follows<PaperProvider reduceMotion>instead of the OS setting;clear()no longer runs the blur animation directly, the label follows the value; label position changes from layout (accessory, RTL) now animate tooSegmentedButtonItem: checkmark spring nowfast.spatialtoken, matchingSwitch/FAB; more overshoot in the expressive theme, almost none in the standard onecode.instructions.md: rule to gate every animation onuseReduceMotion()Follow-up (separate issue): some #5015 files still use imperative
withTimingfor non-spring motion, out of scope here.Related issue
Part of the MD3 motion modernization; no tracking issue yet.
Test plan
yarn typecheck/lint/jestpass, incl. newgetTransition+ TextInput focus/blur and reduce-motion tests. Manual verification + screenshots below.Screenshots
Badge
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-09-08.at.13.08.16.mov
Checkbox / Checkbox Item
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-09-08.at.13.10.19.mov
TextInput
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-09-08.at.12.56.43.mov
Segmented Buttons
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-09-08.at.12.58.39.mov