🔧Setup
Start using TSS, with or without MUI
yarn add tss-react @emotion/react @mui/material @emotion/styledimport { render } from "react-dom";
import { CacheProvider } from "@emotion/react";
import createCache from "@emotion/cache";
import { ThemeProvider } from "@mui/material/styles";
export const muiCache = createCache({
"key": "mui",
"prepend": true
});
//NOTE: Don't use <StyledEngineProvider injectFirst/>
render(
<CacheProvider value={muiCache}>
<ThemeProvider theme={myTheme}>
<Root />
</ThemeProvider>
</CacheProvider>,
document.getElementById("root")
);As a MUI user (if you are using TypeScript >= v4.4), you can simply:
The theme object that will be passed to your callbacks functions will be the one you get with import { useTheme } from "@mui/material/styles".
If you want to take controls over what the theme object should be, you can re-export makeStyles and withStyles from a file called, for example, makesStyles.ts:
./MyComponent.tsx
./makeStyles.ts
./MyComponent.tsx
Last updated
Was this helpful?