jaredh159 / tailwind-react-native-classnames

simple, expressive API for tailwindcss + react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[React-Native] Dark Mode

bezedache29 opened this issue · comments

Hello, I am on React-Native 0.73.2 and I am using twrnc for my styles. My application needs to handle dark mode, and I would like to simplify the task by using the Tailwind classes only once for both light and dark modes. What I mean is, I don't want to have to use text-black dark:text-white everywhere. Instead, I would like the black color in my theme to automatically switch to white in dark mode. This way, every time I use black, it becomes white in dark mode, and the same logic applies to all colors.

On my WebApp, I use tw-colors, and it works very well, but I am having trouble reproducing it in React-Native.

Does anyone have any ideas on how I could integrate this functionality into my project ?

Thank you in advance for your responses.

I haven't tried that approach (either in web, or RN), so I don't have a ton of ideas, but it should be possible. I feel like I've seen @JamesHemery show some code where he dynamically swapped between two different tailwind configs at runtime, maybe he could give you a snippet -- that approach might work here.

(also, converting to a discussion, since that seems to be a better fit for this question)