DEV Community

Discussion on: Adding Tailwind CSS to an Angular project

 
alexanderjanke profile image
Alex Janke

Not an angular person but using Tailwind for quite some time now.
On the tailwind website the common information is that you shall use components as a single source of truth, meaning it doesn't matter if you need 20 utility classes. Your 1 component can be easily managed and changed.
If you want to create a button, you'd create a button component that holds all the styling.
This can be read in way better words than I can explain here. I personally completely avoid @apply. I'd rather create a component.

For global uniformity you can change a lot in the tailwind-config. So if you always want your baseline shadow to be a specific value, go ahead and change it to that. All of your devs can then just use shadow and be happy with the results. This process can be applied to anything within Tailwind.
Since Tailwind is the way it is, it may require some configuration on your end if your team is getting big and you start to notice some inconsistencies.

What really helps is to structure the order in which you use your css classes.
For example, instead of saying:

class="absolute bg-blue-400 top-0 p-2 hover:bg-blue-600 left-0"
Enter fullscreen mode Exit fullscreen mode

you could group the relevant info together

class="absolute top-0 left-0 p-2 bg-blue-400 hover:bg-blue-600"
Enter fullscreen mode Exit fullscreen mode

This is obviously optional. It personally helps me to find classes faster because they always have their place.

Also, on the more practical side:
If you're using VsCode, this is an absolute life-saver

Thread Thread
 
dailydevtips1 profile image
Chris Bongers

Ohh nice! yes, recently added this plugin as well!
To do the order of the classes