| The underlying problem I see that Tailwind solves is component-izing a single idea. And that it doesn't get in the way with opinions like Bootstrap, et al. It does that pretty well. You can point to a single stack of code and say "this one thing is a navbar" and it's easy to know where to make changes. No searching, no stress. What I haven't seen Tailwind do well on my projects is respond to change in the same way other methods would. I'm not saying it isn't possible, just that the several projects I've seen, it was a big pain. A method I've been quite fond of to accomplish the same task, but remove the difficulties this author's other posts articulate, is to recreate the concept of a component in a single folder. Much like you would a Vue single-file component. If you read the "Components" heading here you'll get a good feel for it by looking at the folder/file structure: * https://github.com/flyntwp/flynt#components That same idea I've enabled in a framework/language-agnostic way with an NPM module I created (not public). It watches the folder, namespaces css/js like a single-file Vue component would (using a manifest name or defaults to the folder name). It's a freeing feeling to create a folder and just start coding sass and js without having to wire anything together. As it's auto-namespaced, sass files are very clean too, you can use generic naming like ".heading" without a problem. This solution is nice because: 1. devs get the "one source of editing" in a single folder. Even image assets or your language's logic files. 2. Immense benefit with static analysis tools. Want to assert all your components have a readme.md? or generate docs from all component readmes? Sure. 3. it's performant, with vendor/tree-shaking and inheritance built in. Also parallel build execution of all components. 4. it's agnostic to language/frameworks. Include any linters or unit tests you want. 5. is a paradigm shift from themes to components, just like Tailwind 6. No more wiring together components! specify a global like Vue or your favorite sass package, and all components can inherit it 7. Simple setup.. all you do is point to a folder of components, specify a dist folder, and you're done unless you want to modify specific behaviors I'm curious if there are Tailwinders out there who could teach me if Tailwind solves other problems I'm not seeing. Or if this type of solution would be something I should open source. It ends up being a pretty simple Webpack file under the hood, and it has been an absolute dream to work with over the past year. |
I'm building a RAD platform (I hate the term low code) and just pushed through Tailwind as the only method for styling apps and banned custom CSS.
The primary value Tailwind provides is a reasonably well considered design system. I believe CSS' primary weakness is the general inability to define cross-cutting abstractions. I think of the style of an object as a composition of concerns: spacing, position, size, typography, color, decoration, etc. Programming languages have interfaces or traits or protocols to handle this sort of thing but there's no equivalent in CSS. The addition of CSS variables provides limited ability to do this like you can set up a primary color and use that everywhere but CSS variables alone don't let you set up type or spacing scales. I realized this in 2009 and switched over to defining these abstractions as sass mixins that basically boil down @apply with Tailwind utilities where my mixins were the first part of the utility name and the argument(s) the last part. Having a design system simplifies the job of both the designers and developers. There's no guessing on whether it's a 5px or 6px margin, it's a `margin(2)`. Further, if you pick cooperating scales, the page tends to fall into a vertical rhythm, which is tough to do ad-hoc.
Tailwind is an improvement over my self-designed sass mixins mostly because it has more effort behind it and enough people banging on it that it's been expanded to cover a majority of the CSS you need to implement apps. I add a set of CSS-variable based color names to handle theming (`pri` for primary, `sec` for secondary, `ter` for teritary, and `acc` for accent, with `-dark` and `-light` variations) and allow custom utilities for the project. The latter provides an unsupported escape hatch but is enough friction that I'm hoping people won't abuse it excessively.
For my specific use case there are other benefits:
* No specificity issues
* Having to come up with a name for elements is a significant source of friction in a graphical interface
* Naming CSS classes well requires some concept of the overall system and how the element being targeted fits into it. I do not expect my users to have this knowledge.
* I only allow modification of specific points in a component that have a data- attribute containing component-unique names. This will allow me to change the underlying markup and have a fighting chance at successfully migrating custom styles.
* By breaking the link between styling intent and page structure I have the potential to translate apps into non-browser programming environments.
I find Tailwind markup to be quite ugly and think it doesn't have as much advantage in other situations but it fits my specific problem well.