I think everyone does this differently, but in my opinion your coworker is right. You shouldn't be mixing two different "style types". Either go with styled components or with classnames, but don't mix them. We sometimes use classnames (mainly because a package relies on it) and inline styles (usually because of laziness when its only one property), but only very rarely. We differentiate between a real and a fake/styled component by prefixing our styled components with Styled.. So in your case our import would look something like this: import * as Styled from `./foo.styles.ts` [...] Title Here Answer from AdrnF on reddit.com
๐ŸŒ
styled-components
styled-components.com
styled-components
Here we're saying that when the $primary property is set we want to add some more css to our component, in this case change the background and color. That's all, we're done! Take a look at our finished component: const Button = styled.button<{ $primary?: boolean; }>` background: transparent; border-radius: 3px; border: 2px solid #BF4F74; color: #BF4F74; margin: 0.5em 1em; padding: 0.25em 1em; ${props => props.$primary && css` background: #BF4F74; color: white; `} `; const Container = styled.div` text-align: center; ` render( <Container> <Button>Normal Button</Button> <Button $primary>Primary Button</Button> </Container> );
Documentation
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress
Showcase
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress
Releases
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress
Ecosystem
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress
๐ŸŒ
styled-components
styled-components.com โ€บ docs โ€บ basics
Styled Components Basic
Apart from the improved experience for developers, styled-components provides: Automatic critical CSS: styled-components keeps track of which components are rendered on a page and injects their styles and nothing else, fully automatically.
Discussions

Styled Components Usage, AM I THE COMPLETELY CLUELESS ONE?
I think everyone does this differently, but in my opinion your coworker is right. You shouldn't be mixing two different "style types". Either go with styled components or with classnames, but don't mix them. We sometimes use classnames (mainly because a package relies on it) and inline styles (usually because of laziness when its only one property), but only very rarely. We differentiate between a real and a fake/styled component by prefixing our styled components with Styled.. So in your case our import would look something like this: import * as Styled from `./foo.styles.ts` [...] Title Here More on reddit.com
๐ŸŒ r/reactjs
89
26
September 7, 2023
Is there any good reason to use styled components?
I wonder what you have been reading if it seems unreadable? It's CSS (or more like SASS thankfully) with some small wrapping. const StyledButton = styled.button` position: relative; background: blue; &:hover { background: red; } `; vs #myButton { position: relative; background: blue; } #myButton:hover { background: red; } More on reddit.com
๐ŸŒ r/reactjs
20
0
December 10, 2022
๐ŸŒ
npm
npmjs.com โ€บ package โ€บ styled-components
styled-components - npm
1 week ago - Utilizing tagged template literals (a recent addition to JavaScript) and the power of CSS, styled-components allow you to write actual CSS code to style your components.
      ยป npm install styled-components
    
Published ย  Mar 19, 2026
Version ย  6.3.12
Author ย  Glen Maddern
๐ŸŒ
Josh W. Comeau
joshwcomeau.com โ€บ react โ€บ demystifying-styled-components
Demystifying styled-components โ€ข Josh W. Comeau
When I first started using styled-components, it seemed like magic โœจ. Somehow, using an obscure half-string-half-function syntax, the tool was able to take some arbitrary CSS and assign it to a React component, bypassing the CSS selectors we've always used.
๐ŸŒ
GitHub
github.com โ€บ styled-components โ€บ styled-components
GitHub - styled-components/styled-components: Fast, expressive styling for React. Server components, client components, streaming SSR, React Nativeโ€”one API.
Style React components with real CSS, scoped automatically and delivered only when needed.
Starred by 41K users
Forked by 2.5K users
Languages ย  TypeScript 91.2% | JavaScript 8.6%
๐ŸŒ
Josh W. Comeau
joshwcomeau.com โ€บ css โ€บ styled-components
The styled-components Happy Path: my personal suite of โ€œbest practicesโ€ โ€ข Josh W. Comeau
January 25, 2021 - It's beyond the scope of this tutorial, but we cover it in depth in my comprehensive CSS course, CSS for JavaScript Developers(opens in new tab). Phew! We've covered the high-level โ€œbig ideasโ€ I wanted to share, but before I wrap up, I have a few smaller tidbits I think are worthwhile. Let's go through them. React developers have a reputation for being ignorant of semantic HTML, using <div> as a catch-all. A fair criticism of styled-components is that it adds a layer of indirection between the JSX and the HTML tags being produced.
๐ŸŒ
Smashing Magazine
smashingmagazine.com โ€บ 2020 โ€บ 07 โ€บ styled-components-react
How To Use Styled-Components In React โ€” Smashing Magazine
July 23, 2020 - Styled components are a CSS-in-JS tool that bridges the gap between components and styling, offering numerous features to get you up and running in styling components in a functional and reusable way.
Find elsewhere
๐ŸŒ
GitHub
github.com โ€บ styled-components
styled-components ยท GitHub
A utility-first CSS-in-JS framework built for React. ๐Ÿ’…๐Ÿ‘ฉโ€๐ŸŽคโšก๏ธ ... Fast, expressive styling for React. Server components, client components, streaming SSR, React Nativeโ€”one API. styled-components/styled-componentsโ€™s past year of commit activity
๐ŸŒ
DEV Community
dev.to โ€บ elijahtrillionz โ€บ complete-guide-on-how-to-use-styled-components-in-react-360c
Complete Guide On How To Use Styled-components In React - DEV Community
February 19, 2022 - Styled-components is basically what the name says: "styled-components". Like "this is a styled component (e.g header)". It's a component that is styled not by using a CSS file, but by using CSS syntax in JavaScript (components to be precise).
๐ŸŒ
Reddit
reddit.com โ€บ r/reactjs โ€บ styled components usage, am i the completely clueless one?
r/reactjs on Reddit: Styled Components Usage, AM I THE COMPLETELY CLUELESS ONE?
September 7, 2023 -

Long story short, I'm a newer dev at a company. Our product uses React/TS/StyledComponents. One of the other devs makes a new StyledComponent for every small little thing. Is this good usage? For me it seems easier and more readable to use a P tag and add a classname versus creating a StyledComponent for it. Especially if its just some text with barely any styles to it. So instead of writing...

<p className='title-text'>Title Here</p> they write... <TitleText>Title Here</TitleText> but for everything??

I feel like it causes a lot of context switching where other devs would have to grok whether you are working with another 'actual React component' or not. Then have to go to the style file and see what tag it really is etc. I find it much easier to see a P tag and know exactly what I am working with in a fraction of the time. Am I completely wrong on this?

Top answer
1 of 23
61
I think everyone does this differently, but in my opinion your coworker is right. You shouldn't be mixing two different "style types". Either go with styled components or with classnames, but don't mix them. We sometimes use classnames (mainly because a package relies on it) and inline styles (usually because of laziness when its only one property), but only very rarely. We differentiate between a real and a fake/styled component by prefixing our styled components with Styled.. So in your case our import would look something like this: import * as Styled from `./foo.styles.ts` [...] Title Here
2 of 23
23
Styled components allow you to work with nested DOM selectors, too. For example: const ButtonComponent = styled.button` border: 1px solid var(--color-secondary); padding: 0.5rem; `; You can then have your own wrapping component somewhere where you know this ButtonComponent might be part of, and you can target it specifically to be a child of this Something component's p tag: const Something = styled.container` border: 1px solid var(--color-primary); padding: 1rem; h2 { font-size: 2rem; } p { opacity: 0.8; ${ButtonComponent} { margin-left: 0.5rem; } } `; Your JSX might look like this:

Bla

Bla bla

Not every element needs to have its own Styled-Components declaration. Semantic HTML is supposed to be targeted like this. It's a weaker specificity, but since it's encapsulated in a Styled-Component with generated unique classNames, you'll be more than fine. It's much more intuitive, IMO.
๐ŸŒ
CSS-Tricks
css-tricks.com โ€บ demystifying-styled-components
Demystifying styled-components | CSS-Tricks
June 15, 2022 - With css-modules, youโ€™re applying the styles directly to an HTML element only. With styled-components you can apply the styles to custom components and it will slap the styles on by way of spreading props later.
๐ŸŒ
Gatsby
gatsbyjs.com โ€บ documentation โ€บ how-to guides โ€บ styling โ€บ using styled components
Styled Components | Gatsby
Styled-components are primarily used for a single CSS class that is isolated from other components. In some cases, you want to override global styling โ€” for example, the default margins of your body element.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ styled-components-in-react
How to Use Styled Components in Your React Apps
October 16, 2024 - Styled-components is a library that allows you to write CSS in JS while building custom components in Reactjs. There are multiple options you can go with to style a React application.
๐ŸŒ
DEV Community
dev.to โ€บ pancompany โ€บ styled-components-why-you-should-or-should-not-use-it-23c
Styled-Components: Why you should (or should not) use it - DEV Community
February 29, 2024 - Letโ€™s look at the difference between implementing classic CSS and styled-components. In CSS, you create global styling classes which you inject in your javascript and for every component you determine whether or not it needs a certain classname. Especially in big projects with a lot of components, these classes can overwrite each other, which causes styling inconsistencies in your application.
๐ŸŒ
CSS-Tricks
css-tricks.com โ€บ dry-ing-up-styled-components
DRY-ing up styled-components | CSS-Tricks
November 23, 2020 - I like working with styled-components. They allow you write CSS in your JavaScript, keeping your CSS in very close proximity to your JavaScript for a single component. As a front-end developer who loves to dissect a web page and break it down into reusable components, the idea of styled-components brings me joy.
๐ŸŒ
React School
react.school โ€บ styled-components
Styled Components | React School
As you can see in the above examples, we're using styled-components by first importing it. Then, we can use the styled method, followed by the element we want to style, styled.div, and then add backticks to denote our template which we can add regular CSS syntax into.
Top answer
1 of 3
4

Main benefits of styled-components are listed in the Motivations page on their website.

styled-components is the result of wondering how we could enhance CSS for styling React component systems. By focusing on a single use case we managed to optimize the experience for developers as well as the output for end users.

Apart from the improved experience for developers, styled-components provides:

  • Automatic critical CSS: styled-components keeps track of which components are rendered on a page and injects their styles and nothing else, fully automatically. Combined with code splitting, this means your users load the least amount of code necessary.
  • No class name bugs: styled-components generates unique class names for your styles. You never have to worry about duplication, overlap or misspellings.
  • Easier deletion of CSS: it can be hard to know whether a class name is used somewhere in your codebase. styled-components makes it obvious, as every bit of styling is tied to a specific component. If the component is unused (which tooling can detect) and gets deleted, all its styles get deleted with it.
  • Simple dynamic styling: adapting the styling of a component based on its props or a global theme is simple and intuitive without having to manually manage dozens of classes.
  • Painless maintenance: you never have to hunt across different files to find the styling affecting your component, so maintenance is a piece of cake no matter how big your codebase is.
  • Automatic vendor prefixing: write your CSS to the current standard and let styled-components handle the rest.

With styled components it's possible to "enhance" CSS classes with JavaScript code because are written in JS.

const Input = styled.input`
  color: ${props => props.hasError ? 'red' : 'black'};
`;

Opposed to writing 2 separate CSS classes and control which to show with JS.

.text {
  color: black;
}

.text--danger {
  color: red;
}
<input className={`text ${hasError ? 'text--danger' : ''}`} />

On the long run it can produce more maintainable code, but it's a matter of personal opinion if it's better to use it or not.

2 of 3
4

The reason styled components is pushed in React web development is to encapsulate styles to only those components. There is no risk of bleeding css into other components. Rather than learn a new css organisation structure new developers can onboard more quickly.

That being said, it is restrictive, slower to develop with, and adds some page weight by applying same styles you could have shared.

I have found the fastest way to work is create static html webpages with pure css, and organise it in a way you are going to import it into your framework. Then you can have boilerplate html designs that can be tested independently of the compiler, which is so much faster to test in Internet Explorer, Firefox, chrome, mobile devices and all the varying screen sizes.

If you want to use styled components, you can either use this npm plugin to convert your static css into variables to use with style components - https://www.npmjs.com/package/@inspiraller/create-css-vars

or just don't. Nextjs does not support css imports unless its global, so webpack compiling option is a more universal solution.

๐ŸŒ
Reddit
reddit.com โ€บ r/reactjs โ€บ is there any good reason to use styled components?
r/reactjs on Reddit: Is there any good reason to use styled components?
December 10, 2022 -

I've seen a lot of people hopping on that and more and more people implementing it in their applications. After checking it out I had to hold back both my vomit and tears from seeing what seems like the world's least readable way of using css. Besides the admittedly subjective "Ewwww code ugly" response I tried finding ANY benefit over css frameworks like tw or even just writing it yourself and aside from the typical react lazyness of writing absolutely everything in js i couldn't find good things about it. Also it seems rather rediculous to render css on client runtime (I honestly didn't have it left in me to check out if you could render it ssr on if using Next or something like it). I'm not usually someone who just writes of libraries and frameworks as useless blackbox pieces of shit (except fucking bootstrap ofc) but styled-components seems a lot like that to me. It honestly feels like back in jQuery days where devs just couldn't be bothered with reading up on how dom works and just used that messy shitshow of a library instead.

TLDR; Is there anything I'm missing that is nice about it?

๐ŸŒ
Emotion
emotion.sh โ€บ docs โ€บ styled
Emotion โ€“ Styled Components
It's available from @emotion/styled. styled was heavily inspired by styled-components and glamorous. styled is very similar to css except you call it with an html tag or React component and then call that with a template literal for string styles or a regular function call for object styles.
๐ŸŒ
GetStream
getstream.io โ€บ engineering
Styled Components vs. CSS Stylesheets
November 9, 2020 - When using a CSS framework, this can create an unnecessary learning curve, or at the least, you'll find yourself continually tabbing back and forth to find the correct name of the selector you're trying to override in an ocean of CSS. styled-components make it easy for you to publish a component to NPM and ensure that it is not only super customizable for the user through props and/or extending via styled(Component) but that it always looks & behaves as it did locally due to zero chance of clashing selectors.