|
|
|
|
|
by iaml
2028 days ago
|
|
Styled components are basically html element + dynamically generated class, you get scoping for free (you'd have to use css-modules for that otherwise), and you can define custom props and dynamically modify that component's style. This is extremely useful because one pattern I use frequently is element that has a lot of different modifiers like isSelected or isDeleted, in css you need to define classes for each, but here you just don't return some styles if the prop is not set. You also get full typechecking with typescript for all components, their props and theme. You also get autoprefixer out-of-the-box, and as a bonus if you ever wanted to lazy-load parts of your app, the styles for it should tree-shake correctly without any modifications, unlike traditional css. |
|