Repository navigation
fix(native): seed a concrete scheme-aware __rn-css-color on every platform - #392
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
YevheniiKotyrlo
marked this pull request as ready for review
July 26, 2026 14:52
Contributor
Author
YevheniiKotyrlo
force-pushed
the
fix/root-color-seed
branch
from
October 11, 2026 12:35
d3047d5 to
859dc9e
Compare
This was referenced Oct 11, 2026
YevheniiKotyrlo
force-pushed
the
fix/root-color-seed
branch
from
October 22, 2026 12:37
859dc9e to
3b096e1
Compare
This was referenced Oct 28, 2026
YevheniiKotyrlo
force-pushed
the
fix/root-color-seed
branch
2 times, most recently
from
December 2, 2026 17:42
4206f24 to
1aef39b
Compare
…tform The root seed is `color`'s initial value, `CanvasText`: black, or white in a dark scheme. A semantic `PlatformColor` fallback paints no color from Android's `?attr/textColorPrimary`, and on iOS a border, outline or shadow resolves it against the system appearance instead of the app's scheme, so the seed is a concrete color chosen by the root's own `prefers-color-scheme` evaluation. The tests pin 13 currentcolor consumers and Tailwind's own currentcolor utilities on the compile-time and runtime paths.
YevheniiKotyrlo
force-pushed
the
fix/root-color-seed
branch
from
December 2, 2026 19:00
1aef39b to
c03649b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Problem
A color that falls back to the root
__rn-css-colorcomes out wrong on a device. On Android it is invisible or black wherever it is read; on iOS, border, outline and shadow take the system appearance's variant oflabelrather than the app's scheme, so an app that forces a scheme the system does not have draws them in the other scheme's color. Tailwind v4's default ring color iscurrentcolor, soring,inset-ring,text-currentandborder-currentare the everyday triggers.Root cause
?attr/textColorPrimaryis a ColorStateList, andColorPropConverter.resolveThemeAttributereturnsoutValue.datawithout checkingoutValue.type, so for a ColorStateList the paint receives a value that is not a color. react/react-native#59606 fixes it from 0.89; 0.88 and earlier carry it.UIColorhas to be resolved against the view's trait collection.RCTViewComponentView.mmdoes that for the background alone; its border and outline, andRCTBoxShadow.mm's shadow, read.CGColor, which resolves against the system appearance (react/react-native#57836).Solution
The seed is
color's initial value,CanvasText(CSS Color 4 §3.2), made concrete: black, or white underprefers-color-scheme: dark. The root observable already evaluates a seeded value's media query againstcolorScheme, so the seed stays reactive with noPlatform.OSbranch, noas anyand no eslint suppression. It sits inseedRootRegistry, so the registries' reset seeds it too. An ancestor's color or a:rootcolor still overrides it.Tests
src/__tests__/native/root-color-seed.test.tsx— each of 13currentcolorconsumers compiles to the root color reference and paints#000000in a light scheme and#FFFFFFin a dark one, and so does acurrentcolorheld in a custom property the compiler keeps; no preference, a live scheme change, an ancestor color, a:rootcolor and a scheme-conditioned:rootcolor are pinned as well.src/__tests__/vendor/tailwind/current-color.test.tsx— Tailwind's owncurrentcolorutilities (text-current,bg-current,border-current,outline-current,decoration-current,caret-current,fill-current,stroke-current,ring,inset-ring,shadow-current,placeholder:text-current) in both schemes, and an explicit ring color over the default.src/__tests__/native/box-shadow.test.tsx—currentcolorresolves to the concrete root seed, and aplatformColor()shadow still reaches the shadow as the platform's object.PlatformColordescriptor for acurrentcolorreader now assert the painted color.On
main, 59 cases fail with thePlatformColorseed and all of them pass with this one.Two expectations follow what
maindoes: it mapsborder-inline-start-colortoborderStartColor, and writes acolor-mix()shadow color asrgba().Verification
A local replica of CI passes every job on this head merged into
main, on Node 26.12.1, where.nvmrcpins 24.22.3: lint and typecheck,yarn test --maxWorkers=2 --coverage(2308 passed), the library build withnode --test, the web export and commitlint, and the iOS dev build on macOS with Xcode 27.2, whereci.ymlpins 26.6.Device evidence, Android only, from an earlier revision of this fix: #392 (comment)
Open questions
?attr/colorForegroundpoints at a plain<color>in AppCompat and Material, so it would resolve correctly and keep a custom brand theme's foreground instead of pure black or white. I chose the concrete pair because it is what CSS specifies and whatlight-dark()compiles to here; switching needs a device check I have not run.Known limits
box-shadowortext-shadowwith no color draws black or nothing until fix(native): read a runtime shadow the way the compiler does #489 lands, which reads the omitted color ascurrentcolor.Merge order
#459, #494 and #498 also change
src/native-internal/root.ts, and #489 and #495src/native/styles/shorthands/box-shadow.ts. #391, #489, #495, #501 and #503 add cases that expectmain'sPlatformColorseed. Whichever of this PR and each of them lands second resolves the conflict.