by _akhe · 2y ago · 0 comments
Tailwind:
<div className="shadow-lg" />
CSS: div {
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
Not to mention the Tailwind classNames are compiled to CSS in a build step, where CSS is not compiled, it's written in its native form. They're clearly very different syntaxes and approaches, even though one compiles to the other.The above example shows how convenient Tailwind can be... well if you happen to want that 10px 15px -3px, 4px 6px -4px shadow, but the moment you break out of their palette or default style setup you end up doing stuff like this:
<div className="bg-[#243c5a]" />
Either storing that color value in JavaScript, or creating a Tailwind theme for it in tailwind.config.js: module.exports = {
theme: {
extend: {
colors: {
'regal-blue': '#243c5a'
}
}
}
}
Something that could have been easily accomplished in native CSS: :root {
--regal-blue: #243c5a;
}
div {
background-color: var(--regal-blue);
}
For most React websites, I use Tailwind by default almost always, and Tailwind UI is a great starting point for building a component library. But it still helps to support CSS for more advance styling use cases - even within Tailwind. Knowing CSS very well will make you better at Tailwind too even for common things like <div className="w-[calc(100% - 1rem)]" />
It's kinda important to know both as separate technologies.If I didn't know how box shadow worked, Tailwind made it easier for me to decide by having defaults in the docs that map to the actual CSS.
It's not very extreme, it's literally any time you deviate from their prefab - so any truly custom UI. The size of shadow (corner radius, font-size, etc.) at different steps are hard-coded in Tailwind, if you want something else that's up to you. In terms of colors (text, background, etc.) they have a default palette, colors like "slate", etc. but anything else is up to you. So - most brands.
> Tailwind makes box shadow easier
Easier sure: What it does is give you the abstractions "shadow-sm", "shadow-lg", "shadow-none", etc. in fact a total of SEVEN options for shadows.
That teaches you something - how to apply up to seven types of shadows! But you would be a lot more powerful of a developer if you knew how to do more than that. This doesn't teach you a foundation for understanding box-shadow or learning anything more - I think your point about learning is not valid.
I learned CSS in 2003 from Myspace profiles and Dreamweaver - visual IDEs are great for education, so don't get me wrong here, I'm a believer in what I think you're getting at, but Tailwind aint it (for that).
> if you want something else that's up to you
Right, just like CSS. It's a very light helper library that isn't dissimilar from CSS. That's my point.
Did you ever actually write them fully by hand?
I for one got better with css after using tailwindcss for a while. So Capricorn2481's statement is true at least for me.
Before I used it for a while I've always gone with component libraries, after that I very rarely did... Aside from work projects that mandate specific libraries, anyway
Absolutely. Have for decades. Still do.
This is why I said Tailwind reminds me of an ORM. If you properly know the underlying technology, it just gets in the way.
And CSS is not just about properties. It's also about inheritance and DOM independence, something tailwind doesn't address.
Back in my day we used Bootstrap classes but those guys put -15px margins everywhere so nobody uses their library anymore LOL