Working on my React app with mui themes, I have the following in index.js:
let theme = createTheme({
palette: {
primary: {
main: "#00aaa0",
contrastText: '#fcf4d9',
},
secondary: {
main: "#D55B3E",
contrastText: '#fcf4d9',
},
},
});
theme = responsiveFontSizes(theme);
ReactDOM.render(
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</ThemeProvider>
document.getElementById('root')
);
In one of my components (footer), I am trying to add a top border in the primary color. Currently, footer.tsx has:
const Footer= () => {
return (
<div className="pageFooter">Footer Text</div>
);
};
export default Footer;
I want to style the "pageFooter" so that it uses theme.palette.primary.main as the top border color. In regular CSS, I would do:
.pageFooter {
border-top: 2px solid "#00aaa0";
}
But I want to ensure consistency with the primary color, so I attempted:
.pageFooter {
border-top: 2px solid theme.palette.primary.main;
}
Unfortunately, this approach does not work as the theme is not accessible to the CSS file. I've reviewed the documentation but still confused. Can anyone provide guidance on the correct approach?