DEV Community

Discussion on: Introduction to styled-components

Collapse
 
andresausecha profile image
Andres Ausecha Mosquera • Edited

I do not suggest styled components at all. The syntax is more complex and hinder the reuse of code. Moreover you're using javascript to style your components instead of using pure css or SASS

Collapse
 
arshadayvid profile image
David Asaolu

It's actually pure CSS but just covered with JavaScript to reference the elements to be styled.
For the syntax, I actually find it very easy to install and use quickly.

Concerning the reuse of code, I don't really get that part, if you don't mind may be you can explain.
Cos, I think it's very reusable, with the passing of props into the styles, just like I did in the example above, thereby reducing the number of CSS styles you write.

Also, styled-components optimizes your webpages by loading only the required number of styles you need per component

Collapse
 
ivandack profile image
Ivan Dackiewicz

Hi David. I think Andrés means that with styled components you have all the styling code in the component, which is great to have that component as standalone, but means that you have to rewrite or copy the common styles that are more global or part of the theme when you are working on an app.

Also, the component file may end up being huge, with most of the content being style. Annoying to maintain.

Personally I'm trying a mix between Sass for common styles, and styled components for specific component styles. I won't recommend this yet because I'm still trying it out.

Thread Thread
 
arshadayvid profile image
David Asaolu

Oh! now I get it. I agree with you on this. Rewriting the styles can be timing consuming and huge components😖

Nice, I actually use my index.css file for common styling or copy the styles sometimes.

Thread Thread
 
andresausecha profile image
Andres Ausecha Mosquera

Yeah, after 6 years as fullstack dev I found SASS the best tool for frontend styling, taking into consideration syntax, size, performance and maintainability. In any way, it's a matter of preference, if you like styled components and works for you then go ahead