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:
import { useTheme } from"@mui/material/styles";//WARNING: tss-react require TypeScript v4.4 or newer. If you can't update use://import { createMakeAndWithStyles } from "tss-react/compat";import { createMakeAndWithStyles } from"tss-react";exportconst { makeStyles,withStyles } =createMakeAndWithStyles({ useTheme// OR, if you have extended the default mui theme adding your own custom properties: // Let's assume the myTheme object that you provide to the <ThemeProvider /> is of // type MyTheme then you'll write://"useTheme": useTheme as (()=> MyTheme)});
./MyComponent.tsx
import { makeStyles } from"tss-react/mui";//OR://import { makeStyles } from "./makeStyles";exportfunctionMyComponent(props:Props) {const { className } = props;const [color,setColor] =useState<"red"|"blue">("red");const { classes,cx } =useStyles({ color });//Thanks to cx, className will take priority over classes.root ๐คฉ//With TSS you must stop using clsx and use cx instead.//More info here: https://github.com/mui/material-ui/pull/31802#issuecomment-1093478971return <spanclassName={cx(classes.root, className)}>hello world</span>;}constuseStyles=makeStyles<{ color:"red"|"blue" }>()( (theme, { color }) => ({"root": { color,"&:hover": {"backgroundColor":theme.primaryColor } } }));
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.