Dark mode does not work with CSS modules #3109
Replies: 8 comments 5 replies
-
Help |
Beta Was this translation helpful? Give feedback.
-
@webtinax @bsg3452gwd here is a solution if using
This whitelists the If using
|
Beta Was this translation helpful? Give feedback.
-
I know of 3 ways, css variables, conditional classes in components and with a framework like styled components. Not sure which one to choose. I feel like css variables would allow me to write less code because it takes one action to toggle everything, instead of checking for theme in every component. |
Beta Was this translation helpful? Give feedback.
-
For those who use gatsby this is how I managed to fix it in
|
Beta Was this translation helpful? Give feedback.
-
This still happening today, anyone looking at this problem? I'm facing this issue when running with create-react-app and storybook. |
Beta Was this translation helpful? Give feedback.
-
How can i use next.js v13 /** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
fontLoaders: [
{ loader: '@next/font/google', options: { subsets: ['latin'] } },
],
},
}
module.exports = nextConfig |
Beta Was this translation helpful? Give feedback.
-
I was having this issue. Solved it by using an attribute rather than the "dark" class name. As shown here: module.exports = {
darkMode: ['class', '[data-mode="dark"]'],
// ...
} CSS modules compilation changes the class names but it doesn't change attributes, so those settings work fine. |
Beta Was this translation helpful? Give feedback.
-
Making module.css dark variant mode work with Next:This is what is currently working for me in Next.js v15 which might be helpful for others:
// component.tsx
// layout.module.css
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using Tailwind with CSS modules in Nuxt and it works great — however, dark mode does not work with CSS modules.
If I create a new CSS class and use
@apply
with saydark:text-gray-200
, the dark variant will not be show up. It is as if I did not include a dark variant.Is there something that I am missing? I would love to be able to use Tailwind dark variants with CSS modules. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions