I started my Tailwind journey with react, but I faced one problem. I hate inline CSS because of its poor code readability. So, is there any way to write Tailwind CSS in another separate file and import it into my JSX file, similar to normal CSS.
Is there any way to do this please guide me.
2
Answers
I find one way to do this . we have to import .css file in .jsx same as normal then top of the .css file add this
then you add .class same as normal css and then before you write tailwind just write @apply , then you write your tailwind code there .
This is exactly your .css file look like .
All set.
If you hate inline CSS, maybe you should choose a different approach than Tailwind? The whole idea of Tailwind is that you write your CSS inline, so that it is very close to your component.
Sure you can write wrapper components in a different file:
But then I would really question why you are using Tailwind CSS to begin with.