nativewind: V4: TailwindCSS classes occasionally break.
Describe the bug
The issue extends beyond just the 400 strength colors like bg-red-400 or bg-orange-400; a broader range of Tailwind CSS classes are not functioning properly. The inconsistency in functionality makes it difficult to predict which classes will work.
To Reproduce Steps to reproduce the behavior:
- Clone https://github.com/fendyk/expo-router-typescript-nativewind-example
- Run on android of ios
- Visit the
app/(tabs)/index.tsx - Observe that certain classes do not apply any styling.
Expected behavior All Tailwind CSS classes should be correctly parsed and applied, resulting in the intended styles being reflected on the elements.
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 1
- Comments: 19 (5 by maintainers)
This is still breaking in 4.0.23 I’ve tested this on web, ios and android hardware and also on OSX and WSL. The behavior is similar to what @trevorpfiz is describing. The only difference is that
expo startdoes not work, nor does the tunnel. the behavior is the same either way.on both OSX and Windows 11 (wsl) the web works just fine. -You can add a ‘new’ class like
bg-yellow-500and you’ll see it.on both OSX and Windows 11 (wsl) all hardware devices do not update.
bg-yellow-500you will see it on the web but not on your device.bg-yellow-500in bothglobal.cssnative.css.cssas well asglobal.css.web.cssthe new class will appear,I have reproduced with with a completely newly scaffolded
create-expo-app, and all latest dependencies:Edit: I was able to get this working, and I think I was overlooking something. Its true I was not using the --tunnel flag on WSL which was my last testing environment, but it was also the case that WSL was suppressing port 8089, which was the default websockets port to update the bundle.
If you’re reading this and you have the same symptoms as me - it might be because the fast-refresh and the nativewind ports are two different ports,
8081and8089most likely if you’ve not changed them. In a sense I might have had a similar issue as using--tunnel. If you tried a solution like the one here add8089to the list above. like$ports = @(8081,8089);@fendyk I think we could improve the description a bit. This is not just related to
-400. Many of the Tailwind classes doesn’t work. E.g just useitalic,underlinefor a text. Usew-10,h-20, etc. Flex properties likealign-center,justify-center, etc works. So it’s hard to understand which will work which is not.It’s actually putting the class names to the elements in DOM. But there are no these classes defined in CSS in DOM.
So the problem should be parsing and generating the output CSS file somehow.
cc @marklawlor wanted to share if these helps
On Windows 4.0.15 solved the .js file issue but displays a new error:
I am using https://github.com/fendyk/expo-router-typescript-nativewind-example for testing
This is a different issue. Can you please create a new issue with a reproduction
I’ve noticed that several classes don’t seem to work, but when I restart Metro and delete the cache everything seems to work. It seems to be linked to the problem mentioned in #643. Perhaps this problem should be fixed in the repo as it must be the cause of many doubts and will soon be resolved in upcoming Expo updates.
@enesozturk, could you please test my repo to identify any additional non-functional classes? If you find any, commit your findings, and I’ll merge them into the main branch