3 ms·
The idea with CSS-in-JS is that you don't use selectors. Since you are constructing DOM nodes individually, you don't need to select them. Styled components can
by bastawhiz 8y ago
The idea with CSS-in-JS is that you don't use selectors. Since you are constructing DOM nodes individually, you don't need to select them. Styled components can accept props, which lets you style dynamically (e.g., using an array index to replace `:nth-child`).
With regard to media queries, it depends on the library. For the library the author is using, the media queries are defined inline: https://www.styled-components.com/docs/advanced#media-templates https://www.styled-components.com/docs/advanced#media-templa...
- GordonS 8y agoDoes it use (shared) variables, like with SASS? With SASS, I find it really convenient to define variables for common/brand colours, for example.
- bastawhiz 8y agoYou can define a "theme" object, which you can inject into your styles (with an expression inside the template literal). Other libraries support variables more directly.