My goal is to create a collection of reusable ReactJS components that not only provide functionality but also come with unique CSS themes.
Instead of writing a separate CSS file for each project, I want the styles to be integrated within the components themselves. This way, when I use the components in different projects, they will maintain their intended appearance.
Is there a ReactJS library or plugin available that can help compile these styles within the component, possibly through the use of componentDidMount
?
EDIT
I should mention that I am utilizing MaterialUI, which is a framework designed for implementing Material Design in React applications.
While Material UI offers various components with predefined styles that can be customized, there are limitations to how much we can modify them. Inline styles cannot be added due to the complexity of Material UI's generated HTML structure, so I need to find a way to apply styles directly using selectors in React.
Material UI does have some capability in this area, as shown by the configuration example:
const muiTheme = getMuiTheme({
palette: {
textColor: cyan500,
},
appBar: {
height: 50,
},
});
However, this method only supports certain styles, leaving me in search of a solution for applying all necessary styles to my components.