4 ms·
Let me try to explain CSS in JavaScript to you
- tomduncalf 8y agoPersonally, as a developer who’s main strength is JS but who is okay at CSS (but doesn’t love it!), I can’t imagine working without CSS-in-JS these days. The main selling points for me are keeping styles local to a component (I was using BEM before using CSS-in-JS so this was an easy sell to me - the reality of the cascading part of CSS is it is hard to manage on a team or if you aren’t a CSS expert, so in some ways I see this as damage limitation by introducing boundaries, and making things easier to reason about) and the ability to use JavaScript rather than a bespoke template language to express logic in CSS. I’m currently using the Styled Components pattern (with emotion and React) and I quite like it... feels quite elegant in practice and makes the code nice and maintainable. Interested to get others opinions anyway!