Today I learned I still don’t have a good answer when it comes to managing CSS-in-JS. Last time I discussed this topic I had decided to make a single Styles.js
object that contained style overrides to Material UI. I consolidated all my components styles into that Styles.js
file. Abbreviated example below:
import CustomTheme from "../Theme";
const Styles = {
formPreviewContainer: {
maxWidth: "770px",
paddingTop: CustomTheme.spacing(8),
paddingBottom: CustomTheme.spacing(8)
},
formHeader: {
position: "relative",
paddingTop: CustomTheme.spacing(4),
paddingBottom: CustomTheme.spacing(4),
paddingLeft: CustomTheme.spacing(4),
paddingRight: CustomTheme.spacing(8),
marginBottom: CustomTheme.spacing(4),
backgroundColor: CustomTheme.palette.primary.main
},
// ... other styles omitted for brevity ...
textInput: {
"& .MuiInput-underline:before": {
borderBottom: `1px solid ${CustomTheme.palette.grey[300]}`
},
[CustomTheme.breakpoints.down("sm")]: {
width: "100%"
},
[CustomTheme.breakpoints.up("md")]: {
width: "50%"
}
},
textArea: {
width: "100%",
"& .MuiInputBase-input": {
lineHeight: "24px"
},
"& .MuiInput-underline:before": {
borderBottom: `1px solid ${CustomTheme.palette.grey[300]}`
},
}
};
export default Styles;