Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

darkMode: 'class' in tailwind.config.js not supported #398

Closed
rockmusicmaker opened this issue Apr 7, 2022 · 0 comments
Closed

darkMode: 'class' in tailwind.config.js not supported #398

rockmusicmaker opened this issue Apr 7, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@rockmusicmaker
Copy link
Contributor

Environment:

Current Behavior

setting darkMode to 'class' in the tailwind.config.js and running tailwindcss-classnames -I does not produce any "dark:" prefixed types resulting in typical errors when trying to something like classnames(backgroundColor('dark:g-white')) produces a Argument of type '"dark:bg-white"' is not assignable to parameter of type 'TBackgroundColor .. error. Setting darkMode to 'media' does not cause this.

Expected Behavior

I would expect setting the darkMode property on the tailwind.config.js file to cause tailwindcss-classnames to generate the classes prefixed with "dark:".

How to Reproduce

set "darkMode: 'class'" in tailwind.config.js and run tailwindcss-classnames -i
then try to set a component's className to "classnames(backgroundColor('dark:g-white'))" and observe the error.

Possible solutions (Optional)

I was able to fix this by updating my local TailwindConfigParser.js from:
if (this.getDarkMode() == 'media') mediaBreakpoints.push('dark');
to
if (_this.getDarkMode() == 'media' || _this.getDarkMode() == 'class') mediaBreakpoints.push('dark');

Additional Questions

  • [ x ] I've searched the issues list and this is not a duplicate
  • [ x ] I'm willing to fix this error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant