feat(react-ui): add no-flash color scheme architecture - #824
Open
ankit-thesys wants to merge 1 commit into
Open
Conversation
ankit-thesys
force-pushed
the
codex/no-flash-theme
branch
from
July 22, 2026 23:46
c28ea82 to
97035b0
Compare
ankit-thesys
commented
Jul 23, 2026
Comment on lines
-338
to
-345
| const { mode, theme: userTheme } = useTheme(); | ||
|
|
||
| const barInternalLineColor = useMemo(() => { | ||
| if (mode === "light") { | ||
| return "rgba(255, 255, 255, 0.3)"; | ||
| } | ||
| return "rgba(0, 0, 0, 0.3)"; | ||
| }, [mode]); |
Contributor
Author
There was a problem hiding this comment.
we cant remove this
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.
Fixes #736
Supersedes the approach in closed PR #737. This implementation starts from current
mainand separates global color-scheme preference from scoped theme-token rendering.Problem
OpenUI previously selected dark defaults through
prefers-color-schemeand injected custom/forced theme variables fromuseInsertionEffect. A forced or persisted scheme that disagreed with the device could therefore paint the wrong tokens before hydration, and custom themes painted stock values first. Hydration speed changed how visible the mismatch was; it did not remove the mismatch.Architecture
data-openui-color-scheme, retaining a no-JavaScriptprefers-color-schemefallback.ColorSchemeScriptfor parser-time selection from forced, server-readable, stored, or system preference.ColorSchemeProvider/useColorSchemestore for persistence, system changes, cross-tab synchronization, forced mode, optional transition suppression, and nativecolor-schemesynchronization.ThemeProviderfocused on theme objects, SSR-rendered custom-property rules, nested scopes, explicit modes, and portals. Existing omitted-mode usage without the root provider retains the legacy light fallback.useTheme()retains a deterministic light JavaScript fallback and exposesisModeServerResolved.The detailed research, framework comparison, resolved decisions, security constraints, compatibility requirements, and follow-up instructions live in
packages/react-ui/src/components/ThemeProvider/NO_FLASH_THEME_DESIGN.md.Compatibility
ThemeProvider mode="light" | "dark"remains controlled and server-resolved.moderemains light unless a parent/root color-scheme provider exists.serverMode/serverSystemModefrom a synchronized cookie/request source.Browser validation
Production Next.js tests held JavaScript chunks to inspect the actual pre-hydration paint:
dark; custom dark background/text/syntaxdarklight; custom light background/text/syntaxlightMeasured cost
Verification
pnpm --filter @openuidev/react-ui run ci(43 tests; format and lint pass, with only existing repository warnings)pnpm --filter @openuidev/react-ui typecheckpnpm --filter @openuidev/react-ui build(53 CSS artifacts verified)pnpm --filter @openuidev/react-ui check:publintpnpm --filter @openuidev/react-ui check:attwpnpm --filter openui-chat lintpnpm --filter openui-chat build(Next.js production SSG/SSR)pnpm --filter openui-fastapi-frontend build(Vite 6 production build)