Next.js Discord

Discord Forum

CSS Modules Dark mode: how to import only the themed colors on the server?

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
I'm following this approach to do Server Side Rendering of themes https://github.com/MafinBoy/next-themes-hydration

I'm wondering if I really need to use the .dark class to change theme colors.

Won't be easier to just have different colors-theme.css files with root vars?

/* colors-light.css */
:root {
  --foreground-rgb: 0, 0, 0;
  --background-rgb: 255, 255, 255;
}
/* colors-dark.css */
:root {
  --foreground-rgb: 255, 255, 255;
  --background-rgb: 0, 0, 0;
}

In my RootLayout I can read the theme value from cookies, but I don't know how to import the right colors.css

0 Replies