Skip to content

put reflexGlobalStyles before everything and add style to radix theme root#5763

Merged
adhami3310 merged 2 commits intomainfrom
put-reflexGlobalStyles-before-everything
Sep 5, 2025
Merged

put reflexGlobalStyles before everything and add style to radix theme root#5763
adhami3310 merged 2 commits intomainfrom
put-reflexGlobalStyles-before-everything

Conversation

@adhami3310
Copy link
Member

fixes #5757

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR fixes a critical styling regression in Reflex 0.8.x production builds where wrapped component styles (like table borders) were being lost when running with --env prod. The fix involves three key changes to ensure proper CSS loading order and theme application:

  1. Global styles relocation: The global Reflex styles (reflexGlobalStyles) are moved from the app root level to the document head in compiler/utils.py. A new Link component is added that imports the global CSS file early in the document head, ensuring base styles load before component-specific styles.

  2. App root template cleanup: The app_root_template in compiler/templates.py is simplified by removing the global styles import and the links export function, as global styles are now handled at the document level rather than the component level.

  3. Radix theme synchronization: A useEffect hook is added to the RadixThemesColorModeProvider component that directly manipulates the DOM to ensure Radix theme root classes are properly applied. This addresses theme class application issues in production builds by manually syncing the resolved theme with the Radix root element's CSS classes.

These changes address CSS cascade order issues that occur in production builds where the bundling process affects stylesheet loading sequence. By establishing global styles early and ensuring theme classes are correctly applied, the fix maintains styling consistency across development and production environments while preserving the existing component architecture.

Confidence score: 4/5

  • This PR addresses a well-documented production styling issue with a targeted approach that maintains backwards compatibility
  • Score reflects thorough understanding of CSS loading order issues and appropriate technical solutions for each affected component
  • Pay close attention to the DOM manipulation in the color mode provider as it bypasses React's normal rendering flow

3 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 4, 2025

CodSpeed Performance Report

Merging #5763 will not alter performance

Comparing put-reflexGlobalStyles-before-everything (217a373) with main (dd993fd)

Summary

✅ 8 untouched benchmarks

@adhami3310 adhami3310 merged commit 51f9f2c into main Sep 5, 2025
41 checks passed
@adhami3310 adhami3310 deleted the put-reflexGlobalStyles-before-everything branch September 5, 2025 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In the 0.8.x series --env prod causes the styling of a wrapped component to be lost

2 participants