3 ms·
There are concerns with CSS in JS, but the arguments in this blog post are all very weak or non existant. Structural/Behavioral Vs Graphical The introduction
by K0nserv 9y ago
There are concerns with CSS in JS, but the arguments in this blog post are all very weak or non existant.
Structural/Behavioral Vs Graphical
The introduction of component based tools changes how we design and build our application. No longer is the fact that you can wireframe your whole application valuable instead being able to build individual components and later compose those is valuable. This means that the graphical properties being tightly coupled to a component is actually good.
Loose coupling vs tight coupling
Component based systems can be built with loosley coupled components, but that doesn't mean the components themselves should loosely coupled to their own implementation. This is more analgous to the native platforms too.
Visual Consistency
Claiming that CSS in JS produces visual incosistency is about as true as claiming that CSS does the same. In both cases you can be more or less inconsitent based on your chosen implementation method. In both cases you can move the lowest level design tokens[0] to a single places/system. Arguably Javascript being a more expressive programming language is actually better at achieving consistency via the more powerful variable system.
Code Reuse
Again with a design token system in place changing the design language etc is as easy as changing a few variables.
Personally I think the more interesting problems with CSS in JS is the inability to extract the CSS out into css files to be shipped along the application and how that pertains to server side rendering.
0: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/tokens_intro.htm https://developer.salesforce.com/docs/atlas.en-us.lightning....
- curioussavage 9y agoThe issue with shipping server side CSS is solved in frameworks like styled components too.