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

dark: not working #187

Open
shiftlabs1 opened this issue Apr 1, 2023 · 13 comments
Open

dark: not working #187

shiftlabs1 opened this issue Apr 1, 2023 · 13 comments
Labels
bug Something isn't working

Comments

@shiftlabs1
Copy link

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

@rigor789 rigor789 changed the title dar: not working dark: not working Apr 2, 2023
@rigor789
Copy link
Member

rigor789 commented Apr 2, 2023

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

@rigor789
Copy link
Member

rigor789 commented Apr 2, 2023

@rigor789
Copy link
Member

rigor789 commented Apr 2, 2023

 "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.

@rigor789 rigor789 added the bug Something isn't working label Apr 2, 2023
@vallemar
Copy link
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",

@eltorio
Copy link

eltorio commented Apr 22, 2023

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

@vallemar
Copy link
Contributor

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

@eltorio
Copy link

eltorio commented Apr 22, 2023

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

@rigor789
Copy link
Member

rigor789 commented Jan 5, 2024

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

tailwindlabs/tailwindcss#12584

Removing that in 149d676

@rigor789
Copy link
Member

rigor789 commented Jan 5, 2024

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

@vallemar
Copy link
Contributor

vallemar commented Jan 5, 2024

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

@rigor789
Copy link
Member

rigor789 commented Jan 5, 2024

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

@bradrice
Copy link

bradrice commented Mar 28, 2024

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.

@jkod
Copy link

jkod commented Apr 29, 2024

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

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

6 participants