๐งSetup
Start using TSS, with or without MUI
tss-react
has over 170 000 monthly NPM download and fewer than 220 โญ๏ธ on GitHub.
If you use TSS in production, please consider giving the project a star.
If you are migrating from @material-ui/core
(v4) to @mui/material
(v5) checkout the migration guide from MUI's documentation website here.
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
Keep @emotion/styled
as a dependency of your project.
Even if you never use it explicitly, it's a peer dependency of @mui/material
.
Storybook: As of writing this lines storybook still uses by default emotion 10.
Material-ui and TSS runs emotion 11 so there is some changes to be made to your .storybook/main.js
to make it uses emotion 11.
You can detect unused classes with this ESLint plugin.
If you don't want to end up writing things like:
You can put "baseUrl": "src"
in your tsconfig.json
and import things relative to your src/
directory.
Last updated