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

Issue with Dark Mode Styles After Upgrading to Tailwind CSS v3.4.0 #710

Closed
mdwekat opened this issue Dec 20, 2023 · 3 comments
Closed

Issue with Dark Mode Styles After Upgrading to Tailwind CSS v3.4.0 #710

mdwekat opened this issue Dec 20, 2023 · 3 comments

Comments

@mdwekat
Copy link

mdwekat commented Dec 20, 2023

Upon upgrading to Tailwind CSS v3.4.0 in a NativeWind project, there is a noticeable issue where the dark mode style modifiers fail to function. This problem specifically occurs with the new version of Tailwind CSS, impacting the application of conditional dark mode styles.

To Reproduce
Steps to reproduce the behavior:

  1. Set up a NativeWind project with nativewind version 4.0.16.
  2. Upgrade Tailwind CSS to version 3.4.0.
  3. Configure dark mode in the application to apply styles using the class method.
  4. Implement a component with distinct styles for dark mode. Example code:
    return function Test() {
      return (
        <View className="bg-red-500 dark:bg-blue-500">
          <Text>Hello!</Text>
        </View>
      );
    } 

Expected behavior
The component should display a blue background (dark:bg-blue-500) in dark mode.

Actual Behavior
The component maintains the red background (bg-red-500) irrespective of dark mode activation, indicating a failure in applying the dark mode-specific styles.

Additional context
This styling issue was not present before updating to Tailwind CSS v3.4.0.

@marklawlor
Copy link
Collaborator

Please provide a full reproduction. This could be caused by a number of reasons and there is not enough information here for me to provide you an explanation.

@mdwekat
Copy link
Author

mdwekat commented Dec 23, 2023

Maybe this has something to do with it
PR #12584

Update:
Somehow setting the darkMode to media in my tailwind.config.js fixed the issue.

/// tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
  darkMode: 'media',
  // ...
}

Update 2:
Here is a minimal RN app that shows the issue
https://github.com/mdwekat/nw-tw-3-4

Notes:

  • when setting the darkMode from media to class you need to rebuild the app and open it again.
  • Tested on ios only.

@mdwekat
Copy link
Author

mdwekat commented Jan 5, 2024

After upgrading tailwindcss to v3.4.1 the issue has been resolved I think they rolled back to the old behavior of applying the dark mode (#12717)

@mdwekat mdwekat closed this as completed Jan 5, 2024
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

No branches or pull requests

2 participants