Tag: css-modules

css-modules theme provider

For a recently started React project I chose for css-modules over Styled Components. It is not so much whether one is better than the other, but which one suits the purpose of your project better. Where CSS Modules is a CSS-preprocessor and Styled Components a Javascript Framework Component. Can’t decide ? I found this a good 11 minute read to make my decision A requirement for this project is that it can easily, preferably dynamically, alter color patterns. Initially, switching from a dark theme to a light theme will suffice. But the possibility to switch between multiple color schemes would be nice. I chose for css-modules, and therefore my DuckDuck.go search for a convenient package began. I found some packages, and solutions. But in summary, I felt the solution should be easier. Also, I would like to be able to insert the theming solution into an existing project without too much effort. So here it goes… Consider the following React component which shows a very fancy text with a apple green background. I would be nice if the background color of the component could be changed dynamically. E.g. by using a css variable for the background and changing the value…