Tailwind is a CSS library in a similar space to things like Bootstrap or Bulma. Tailwind is different that instead of providing CSS for full co...
For further actions, you may consider blocking this person and/or reporting abuse
You can simplify it a bit more with the following.
to
You do this by updating the babel macro config with something like
Hey Ryan,
Very nice! I'm not familiar with Tailwind.Macro or babel-plugin-tailwind-components. Would they provide the same cut-what-is-not-needed benefits as PostCSS + Purgecss, or would you consider using both?
That's a great question and I'm not entirely sure right now. I tried to find a bit more info on it but to no avail. I have a project where I'm using this and next time I'm in the code, I may try to do a production build and see if it's doing any of the purging type operations.
If it's not, it'd likely be good to do that still :D
Very nice! Thanks
Ryan! Thank you very much for your demonstration. You managed to sell Tailwind far better than anyone else has.
I’m a CSS specialist, my primary focus is designing efficient style workflows. I love styled-components.
I’ve been wanting to bring Tailwind on for awhile because there are several huge benefits as the UI styling is predictable and very nice to work with.
I absolutely cringed at the utility classes overtaking the template. React can get busy all on its own without Tailwinds class pollution.
The styled-component method is a game changer and now I have a new style workflow to integrate. Exciting!!! 🙌🙌
Thanks a ton for checking it out - so glad it was helpful! :D
I had a very similar reaction when looking at Tailwind initially. "This looks nice but I fear what it'll turn my components into" 😀
Thank you for the article Ryan. I still can't understand tailwind approach that looks very similar to me with writing styles inline. So there are no difference between writing for example div class="overflow-hidden" and style="overflow:hidden".
Thank you. This is totally understandable that it looks similar to inline styling on occasion. I prefer the Tailwind approach using "micro CSS classes" opposed to inline styling. It shines when you have more properties you're applying especially on more than one page. If we wanted to apply a background, rounded corners, font-size, etc. it would be more like
class="bg-indigo-300 rounded text-sm"
(etc.).Since these are classes and not inline, if we ever needed to update what font was used, anything using the Utility class would be styled the same. Tailwind's theme docs for a little more on this.
I would say the main benefit of tailwind is that it provides you with a consistent design system which scales well. you don't need to think about what is degree of green I need to use as background and what is degree of green I need to use as the text color. simply use the pre-defined class like text-green-100 or text-green-500 without thinking about the hex color. It also works the same way for scaling the font size, without thinking about what specific font size used for heading or paragraph. Simply try text-lg, text-base to see how it fits your design.
Thanks for this good article!
How would you create the tailwind string parameter programmatically?
If let's say I want to add tailwind classes dynamically how would this work?
I tried adding my tailwind classes to a string and the pass it to the macro as a parameter but it doesn't seem to work.
This works if rather than using the$(twStr) I use "pt-16 pb-16" (as a string a not as a variable).
Any hint?
Hello Ryan! Thanks for the tutorial!
I was using Tailwind with the PostCSS + Autoprefixer method and I thought that changing to styled-components would be an easy solution for when you want to disable a button or an input field.
But the main thing is that the Base style, they call it "Preflight", doesn't work anymore. Before I had this huge CSS file that was imported to my App, and the margins, paddings, and fonts were all working fine.
Now I have no clue on how to load these base styles. Do you have any idea on how to to that?
Thanks!
Nice work Ryan 👍
Thank you :D