React styled components with Sass
Hey guys, more of a general question so forgive me if some things are not clear. I'd like to use styled components in React as it seems to make changing styles way easier than if I followed the 7-1 Sass pattern. My only concern is what would the folder structure look like if I want to have global variables/functions/mixins? Would it be possible to get a quick folder structure that you use?
4 Replies
With styled components you have one parent component that wraps the entire app which takes on prop, theme, which is an object containing css styles.
And then theme is just an object you can place in some other directory, and is just an object:
Right that makes sense but maybe I misunderstood but I'm thinking about it more in a stylesheet sense. So for example, here is my project structure:
Pretty typical project structure from what I've seen. But then I want to add a gloabl scss stylesheet that I can import in any of my components. Where would I put that? Should I make a separate directory? What's common practice?
Well, I don't know really what common practice is since react doesn't enforce a particular structure so every project follows their own. However what I do is create a
common
directory that shares anything that is meant to be accessible throughout the app.
For example:
Where a feature is a specific part of the app and contains components and other logic related to that domain specifically. Common includes things that are shared like buttons or modals, but also styles or hooks
There was a recent question asked on this with a couple of links that may be useful: https://discord.com/channels/436251713830125568/1067208053985918996/1067208053985918996Thanks a lot!