
Let's now take a quick look at what styled-components is, and how it works which will get us acquainted with the styled-components syntax. It's a component that is styled not by using a CSS file, but by using CSS syntax in JavaScript (components to be precise). Like "this is a styled component (e.g header)".

Styled-components is basically what the name says: "styled-components". This time I could style everything and anything I want without worrying about conflicts and without using class names in my JSX. Then I came across styled-components that changed everything. Am not saying Tailwind is bad, I just don't like the way it makes my JSX bucky and rough. I made a simple form with it, and I felt like I have made a full website, with lots of overwhelming abbreviated class names that I don't understand. Then there is Tailwind, this is where some developers have come to rest, but for me it made my JSX look too scary. But still, this is not my best approach for scaling apps, because of semantic class names. Conflicts do not exist because the styles from any CSS file will only be used if called upon as a class name. In Next.js, each page/component can have a dedicated style (CSS file). Then there is Next.js (CSS module) which has done a marvelous job in simplifying this approach for its users. Some can organize this approach properly, but it still is very hard. This will cause a conflict, you will end up using important half the time in your child page/component. One of which is that a child page/component that has its own style will also inherit the styles of the parent page/component.
#INSTALLBUILDER CONDITIONALLY INCLUDE COMPONENT HOW TO#
Initially, I was confused about how to structure my CSS files, thoughts like "should I dedicate a specific CSS file to specific pages? or should I just use one file for the whole app (which is scary, but I've done it :))?" are always roaming through my head when I am creating a new app in React.ĭedicating a CSS file to a specific page or component is ideal, but there are backsides to this.

I have often found styling a React application very confusing and difficult.
