ThemeProvider Not Applying Styles in Vite Setup #5664
Unanswered
luislufttech
asked this question in
Q&A
Replies: 1 comment
-
Things seem to have broken in 3.6.0+ ish |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm facing an issue where ThemeProvider from @primer/react does not apply styles dynamically unless I manually import @primer/css/dist/primer.css.
When I import @primer/css manually, styles apply correctly.
When I rely solely on ThemeProvider, components lose styling, even though useTheme() returns correctly structured theme values.
I'm trying to understand why this is happening and whether this is expected behavior or a potential issue with Vite's handling of @primer/react styles
What I've Already Tested
✅ Ensured ThemeProvider wraps the entire app correctly
✅ Checked useTheme() logs - it returns correct theme values.
✅ Verified CSS variables in DevTools - they are missing unless I import @primer/css.
✅ Tried pre-bundling @primer/react in vite.config.js using optimizeDeps.
✅ Disabled Fast Refresh in Vite to ensure ThemeProvider is not resetting.
✅ Forced data-color-mode="light" in to ensure correct application.
✅ Manually injected CSS variables using useEffect, which forces styles to apply.
This is App.jsx
export default App;
Setup Environment
React: 18.3.1
Vite: 6.0.5
Browser: chrome
Ubuntu 22.04 on WSL
@primer/react: 37.11.0
@primer/css (manually importing for now): 21.5.1
Beta Was this translation helpful? Give feedback.
All reactions