Skip to content

dark: not working #187

Open
Open

Description

@shiftlabs1

Can anyone help me understand this statement in the readme

 // use the .ns-dark class to control dark mode (applied by NativeScript) - since 'media' (default) is not supported.
      darkMode: ['class', '.ns-dark'],

As when i use

bg-teal-500 dark:bg-cyan-700

for example , the styling does not get applied when using dark mode on the phone, only the default bg-teal-500 is ever applied .
I even added it as a plugin in the config

  plugins: [
        plugin(function ({ addVariant }) {
          addVariant('android', '.ns-android &');
          addVariant('ios', '.ns-ios &');
          addVariant('dark','.ns-dark &')
        }),
      ],

still no Joy. What am i doing wrong

Thanks

Activity

  1. changed the title [-]dar: not working[/-] [+]dark: not working[/+] on Apr 2, 2023
  2. rigor789 commented on Apr 2, 2023

    @rigor789
    Member

    I will investigate, it's supposed to work - but perhaps a recent tailwind update "broke" something for us...

  3. rigor789 commented on Apr 2, 2023

    @rigor789
    Member
  4. rigor789 commented on Apr 2, 2023

    @rigor789
    Member
     "tailwindcss": "3.3.0",
    

    and above breaks it - will dig further.

    Edit: looks like it's changed the selector strategy in here: tailwindlabs/tailwindcss#10766

    Will figure out a fix soon - until then keep your version < 3.3.0 and it should work fine.

  5. vallemar commented on Apr 11, 2023

    @vallemar
    Contributor

    Same problem here, the problem is that with the version in the package ^3.1.8 the 3.3.1 is downloaded, this is going to mess up a lot of people. To use the specific version remove the ^ from the version of package.json

    //Before:
    "tailwindcss": "^3.1.8",
    
    //After:
    "tailwindcss": "3.1.8",
    
  6. eltorio commented on Apr 22, 2023

    @eltorio

    same here dark is working with 3.2.7 but not with 3.3.0 nor 3.3.1 while using dark in class mode

  7. vallemar commented on Apr 22, 2023

    @vallemar
    Contributor

    @eltorio you must use the "tailwindcss": "3.1.8" version while it is fixed

  8. eltorio commented on Apr 22, 2023

    @eltorio

    @vallemar
    I have no problem with 3.2.7, just with 3.3.x

  9. rigor789 commented on Jan 5, 2024

    @rigor789
    Member

    Seems like the selectors have now been changed again in 3.4 to :is(:where()):

    tailwindlabs/tailwindcss#12584

    Removing that in 149d676

  10. rigor789 commented on Jan 5, 2024

    @rigor789
    Member

    @nativescript/tailwind@2.1.0-rc.2 seems to work with latest TailwindCSS now!

  11. vallemar commented on Jan 5, 2024

    @vallemar
    Contributor

    @rigor789 What more properties can we use now that we have :is working?

  12. rigor789 commented on Jan 5, 2024

    @rigor789
    Member

    Not sure, :is is downgraded to a similar css syntax for now using @csstools/postcss-is-pseudo-class.

  13. bradrice commented on Mar 28, 2024

    @bradrice

    I can't seem to get dark to work even with the rc. I might not know how to do it. The docs aren't very clear to me. I've added darkMode: ["class", ".ns-dark"], to my tailwind.config.ts. I don't see .ns-dark being added to my html file anywhere. If I manually add it to a selector, that works, but even when I am in light mode. How do I get it to work conditionally? It would be nice if there were a demo app with the dark theme working.

  14. jkod commented on Apr 29, 2024

    @jkod

    I can't seem to get dark to work even with the rc. I might not know how to do it. The docs aren't very clear to me. I've added darkMode: ["class", ".ns-dark"], to my tailwind.config.ts. I don't see .ns-dark being added to my html file anywhere. If I manually add it to a selector, that works, but even when I am in light mode. How do I get it to work conditionally? It would be nice if there were a demo app with the dark theme working.

    The selector strategy replaced the class strategy in Tailwind CSS v3.4.1.

    Try this instead: darkMode: ['selector', '.ns-dark']

    I just updated my sample app to all latest dependencies where you can try out dark mode :-)

    https://github.com/jkod/nativescript-tailwind-angular-starter

  15. stephenjason89 commented on Jul 29, 2025

    @stephenjason89

    in tailwind 4 dark: doesnt work as well.
    I'm trying to use custom dark class

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions