Demystifying styled-components

No Comments

 Joshua Comeau digs into how styled-components works by re-building the fundamentals. A enjoyable and helpful journey.

styled-components looks as if the most important participant within the CSS-in-React market. Regardless of being in that world, I haven’t but been totally compelled by it. I’m an enormous fan of the fundamentals: scoped kinds by the use of distinctive class names. I additionally like that it really works with sizzling module reloading because it all occurs in JavaScript. However I get these by css-modules, and I just like the file-separation and Sass help I get by css-modules. There are some things I’m beginning to come round on although (a little):

Even with css-modules, you continue to have to think about names. Even when it’s similar to .root or no matter. With styled-components you connect the kinds proper to the element and don’t actually title something.With css-modules, you’re making use of the kinds on to an HTML ingredient solely. With styled-components you possibly can apply the kinds to customized parts and it’ll slap the kinds on by the use of spreading props later.As a result of the kinds are actually within the JavaScript recordsdata, you get JavaScript stuff you should use—ternaries, prop entry, fancy math, and so forth.

Direct Hyperlink to ArticlePermalink

The submit Demystifying styled-components appeared first on CSS-Tips. You’ll be able to help CSS-Tips by being an MVP Supporter.

    About Marketing Solution Australia

    We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.

    Request a free quote

    We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.

    Subscribe to our newsletter!

    More from our blog

    See all posts

    Leave a Comment