References
Introduction to React styling
Notes
- note that both CSS approaches have to use the
style
prop for dynamic styles
CSS Modules
- just import some CSS
- must be named
*.module.css
- classes automatically scoped, worry free naming
- CSS bundled with component
CSS in JavaScript
-
common pattern in React apps provided by libraries
-
styled-components
most popular- Automatic critical CSS
- No class name bugs
- Easier deletion of CSS
- Simple dynamic styling
- Painless maintenance
- Automatic vendor prefixing
-
fantastic for dynamic styling
-
component fully contained in single file
-
needs extension for syntax highlighting