How do you manage your sass/scss or any other styling files on react?
Saugat Rai

Saugat Rai @raisaugat

About: Been working with frontend stuff and lately more into React

Location:
Kathmandu, Nepal
Joined:
Mar 31, 2019

How do you manage your sass/scss or any other styling files on react?

Publish Date: Jul 24 '19
6 6

How do you structure your styling files on react? Do you use styled-components or do you use sass/scss?

Comments 6 total

  • Suzanne Aitchison
    Suzanne AitchisonJul 24, 2019

    We keep our components in folders, with their own Sass style file in there with them. And then additionally global Sass and variables files at the top level. I quite like this structure as it keeps component styles separate but doesn't pollute the JS with styling code.

    I've noticed more people seem to be moving towards declaring their component styles in the JS though and would be keen to know why!

    • Saugat Rai
      Saugat RaiJul 24, 2019

      I also like the idea of placing the Sass file in the same component where it is use.
      Using styled component is quite useful, but I think it makes the jS file very long.
      Anyways, thanks for you opinion. :)

  • Michał Czarnota
    Michał CzarnotaJul 24, 2019

    Me and my team use css modules (without .module extension) and sass with scss notation. Each .scss file is in the same dir in whic .jsx file is. We have structure like src/components/Avatar/Avatar.scss and import it as module in .jsx file.
    Also, there are some files in src/styles dir, that contain some global variables.

    I tried some ways of styling in JS apps and I found this way the simplest, cleanest and fastest 🏇

    • Saugat Rai
      Saugat RaiJul 25, 2019

      Cool. I think this approach is much cleaner than styled components. But have you tried styled components? And what are your thoughts on this?

      • Michał Czarnota
        Michał CzarnotaOct 23, 2019

        Soon after your comment we decided to use styled-components in part of our system. It's been a while with them, so I've got some thoughts.

        1. It's so easy to style components, depending on props!
        2. It's so hard to debug nested components!
    • gmantovani97
      gmantovani97Jul 30, 2021

      How did you configured it to not use the .module extension? Probably you did it inside webpack, but could you share the code?

Add comment