Tailwindo: Convert Your Bootstrap CSS to Tailwind CSS
awssat.com
awssat.com
But I do wonder if inlining classes into each and every element is as efficient as CSS rules that apply to those same elements.
Imagine you have a table with a few hundred cells. You can have something like:
.my_table .cell { ... }
Or repeat those classes in each cell. Is there a performance, memory etc impact?
Performance is more complicated, but generally it's never an issue. We've had huge webpages forever, often with many different CSS files and HTML included from all across an application and organization. When the browser has all of the CSS files finally loaded into memory, it's FAST.
Here's an old article[0] that looked into some performance metrics. 7000 DOM nodes per page, with crazy nested selectors. The delta between the different tests was around 10% (10-100ms depending on the browser) from the simplest to most complicated, but the absolute rendering time has was still under 200ms for all browsers. Important to note that this test was also conducted when IE9 was still relevant. Computers, and even low end devices, are much faster than what was available in that era.
I reran the tests from the article in Chrome just now, and the insanity selector test ran consistently in under 100ms on a 2020 quad core MacBook Pro. Chrome's performance benchmarking tools confirmed that number as well as the simple benchmark included in the test source.
We also have to take into account that the types of classes included with atomic CSS frameworks are extremely simple for browsers to parse and apply. Because they aren't deeply nested spaghetti, the browser can more quickly index them for use later in the rendering lifecycle.
I would be interested to see what the effects are of atomic CSS on performance using our modern browser environments, but I would guess it's negligible and not relevant compared to any other part of the page rendering and refresh lifecycle.
0: https://benfrain.com/css-performance-revisited-selectors-blo...
If all your classes are in an apply, why not just use the CSS? most of the utility classes are one line classes
And even better, if you work at a place where a custom design system is needed, Tailwind has pretty much everything you need to customize your own but still give the same Tailwind productivity to developers.
Do these theme.js files have full sizings, spacings, etc defined?
It’s all going to depend on what sort of optimisations are done by the browser. They could very well cache style rules by class combination hashes. (They probably don’t, but it’s possible).
Whatever happens, in my case it’s going to be better than the laggy material ui and css-in-is tooling we were using before.
You can use Tailwind to build Bootstrap, like the OP link shows, but you can't do the opposite. I was surprised when browsing the Tailwind docs that they didn't have prebuilt navbar, form, or input classes, but now I realize that's actually the point. You have to build all of those yourself to fit the needs of your project. That's not to say that prebuilt components don't exist at all, just that they're not part of the Tailwind framework project - they exist under Tailwind UI, the commercial offshoot of Tailwind. It's pretty expensive as an indie developer, but I don't mind having to build my own components so it still works out for me.
In the more traditional method, you would style a <button> element in a CSS file and never think about it again, while it inevitably becomes part of the CSS nest. If you wanted to use tailwind for a normal non-component based site you'd have to individually style every single button again and again, as there's no cascading and no globally applied styles. I wouldn't use tailwind in that cirucmstance.
But because it's more likely you're using vue/react and your buttons are actually defined as a <Button> component that you re-use, you can write the styles directly on the component where it's used, co-locating the code and making maintenance a bit easier in the process.
Yeah, I also understand Tailwind as inline-styles without it's problems:
* it provides less choices (instead of 256*3 colors you have limited choices)
* classes are (a lot) faster than inline styles in most browsers
* has access to features that inline styles can't (e.g. media queries)
Although, I guess I don't know for sure until I start to test the product. But the development at least has been a blast.
The "simplest" button apparently contains the following ridiculous number of css classes, which is not the kind of css composition I'm a fan of. It may be the most flexible in terms of customization, but it's a nightmare to mentally parse and maintain. I would not want to manage a code base where nearly every html tag looks like this. :/
<button type="button" class="inline-flex items-center px-2.5 py-1.5 border border-transparent text-xs font-medium rounded shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"> Button text </button>
I don't think a css framework that charges 200, 400 or 800 (team pricing) for the standard ui components will ever reach that status.
Tailwind by itself is intended for people who don’t want the pre-made components you get with Bootstrap etc.
It's the 'hot topic that gets eyeballs and talk' but that doesn't reflect the same level of general usage.
A little like Vue got all the articles for a while, and don't get me wrong it's very nice, but adoption generally isn't as high as you might think based on discussion and blogs and etc.
[1] https://github.com/github/view_component/ and https://viewcomponent.org
https://mobile.twitter.com/samthor/status/140282566806113075...
The point of atomic/utility CSS is to have a well defined and composable subset of rules. I suggest you seriously try it. I was surprised after a short while. It’s a very productive approach.
At the level of class-per-CSS-property it just makes no sense to me. CSS properties are a well-defined and composable set of rules too.
And actually, today for the first time in ages and ended up having to add “real css” to style an input[range] and it was so weird and disjointed to me to not define it right where I needed it.
You can use PostCSS to define class that compose multiple tailwind classes together (See how @apply is used here: https://tailwindcss.com/docs/using-with-preprocessors).
My flow is usually to iterate by adding individual classes directly to HTML elements, and when I see a pattern emerge I'll sometimes make a new class with that inherits from multiple tailwind classes.
Any more examples of what the transform(s) look like? Ie. Given some input, this is the output?