I'm following the tutorial on mui's website to get the version 5 of the framework in place. Everything is fine except that I cannot figure out how to make the styled components work.
Here is a minimal example with a sandbox to try it out:
import React from "react";
import { render } from "react-dom";
import { createTheme, styled, ThemeProvider } from "@mui/material/styles";
import { Button } from "@mui/material";
const theme = createTheme({
palette: {
primary: {
main: "#4cfcb3",
light: "#8affe5",
dark: "#00c883",
contrastText: "#000"
},
secondary: {
main: "#00b0ff",
light: "#69e2ff",
dark: "#0081cb",
contrastText: "#FFF"
}
}
});
const Test = styled(() => <div>TEST SHOULD BE RED</div>)({
color: "red",
backgroundColor: "#000"
});
const App = () => (
<ThemeProvider theme={theme}>
<Button color="primary" variant="contained">
Hello Button
</Button>
<br />
<br />
<Test />
</ThemeProvider>
);
render(<App />, document.getElementById("app"));
In this example, we can see that the button correctly gets the colors as specified in the theme, so that.s good, but my Test styled component isn't styled at all as you can see here:
What am I doing wrong?
