Twitter | Search | |
This is the legacy version of twitter.com. We will be shutting it down on 15 December 2020. Please switch to a supported browser or device. You can see a list of supported browsers in our Help Center.
Matija Marohnić 18 Oct 18
Users of CSS-in-JS, I need a favor. Do you have examples where CSS-in-JS really shines over CSS Modules + PostCSS? In this context let's assume that using CSS custom properties is fine, even though IE doesn't support them.
Reply Retweet Like
Nasty Claus
Some bits I like - - exact critical css extraction - never having to use !important, ie. fewer bugs - exact code splitting - like css vars, but for whole rules But really, my favourite reason, is how little I think about it when I’m prototyping something. Great for focus.
Reply Retweet Like More
Nasty Claus 19 Oct 18
Replying to @silvenon
I agree and empathise that it isn’t perfect, but given the right context and constraints, it’s a pretty sharp knife, and you can always swap it out for something more prod-worthy later.
Reply Retweet Like
Matija Marohnić 19 Oct 18
Replying to @threepointone
Thanks so much! I use CSS-in-JS quite a lot, so my angle wasn't to diminish its value. My favorite CSS-in-JS feature is brevity, i.e. the delightful "styled" shortcut. It's so easy to create a styled component, and you often have to create <div> elements just to style them.
Reply Retweet Like
Satyajit Sahoo 19 Oct 18
Do you know any examples of this? "like css vars, but for whole rules" I always see this come up, but I have never needed it personally, and haven't seen it a codebase. Is it a common usecase?
Reply Retweet Like
Nasty Claus 19 Oct 18
Replying to @satya164 @silvenon
Pretty common. [styles.button, isRecommended && styles.highlight]
Reply Retweet Like