News for hackers. Stuff that matters.
Re:Signals for Tailwind CSS (styling based on ancestor state... by paulddraper on Saturday August 31, 2024 @04:51PM (#41411849)
The last paragraph sounds like CSS-in-JS
Re:Signals for Tailwind CSS (styling based on ancestor state... by krsdcbl on Saturday August 31, 2024 @06:45PM (#41412612)
Tbh I never really understood the reason for the existence of css-in-js either.

Just do vanilla `<style> @scope { /* your component styles without any naming bloat ... */ } </style>` nested in the markup/jsx, and optionally leave merging any of that for perf optimisation to some rudimentary build tooling or hydration

But also: I do see the QoL benefits of colocating styles & markup, but it has drawbacks aswell: it prevents you from being able to reuse design systems across different applications/codebases, and increases maintenance complexity and tech debt as soon as you introduce utility classes or any styling rules that aren't hard-tied to a singular component. Both issues scale painfully fast with the complexity of your App/UI, and impact Tailwind-based UIs even more in my experience.

Re:Signals for Tailwind CSS (styling based on ancestor state... by paulddraper on Sunday September 01, 2024 @12:35AM (#41414327)
For one thing, Firefox.
Re:Signals for Tailwind CSS (styling based on ancestor state... by muratsu on Saturday August 31, 2024 @05:03PM (#41411949)
This is what most people want + some utility functions & good default variables (for colors etc).

If you're doing relatively straightforward things, tailwind is super easy to work with and that's why a lot of people prefer it today. Having it inline makes it easy to digest (both for humans and LLMs) until things get complicated.

I see this similar to using javascript in your project. When you start fresh on a new project, typescript can be seen as a bottleneck, slowing you down. As project evolves your needs also evolve and other solutions might be a better choice.

Re:Signals for Tailwind CSS (styling based on ancestor state... by koito17 on Saturday August 31, 2024 @05:08PM (#41411990)
CSS-in-JS solutions like Emotion provide something close to that! But they come with some drawbacks (e.g. needs careful setup for server-side generation, spends a few CPU cycles translating to CSS, breaks memoization unless one uses deep object comparison or stores the style data separately from the component).

CSS modules provide a great alternative if one is willing to write CSS in separate files. Otherwise, Tailwind has provided a smoother experience than CSS-in-JS for me.