Replies: 3 comments 9 replies
-
|
@kpervin Yes, What I think of would look like this: import { useTheme } from "@mui/material/styles";
import { unstable_styleFunctionSx as styleFunctionSx } from "@mui/system";
import { createMakeAndWithStyles } from "tss-react";
export const { makeStyles: makeSxStyles } = createMakeAndWithStyles({
useTheme,
"customObjectToCssObject": ({ customObject: sx, theme }) => styleFunctionSx({ sx, theme })
});We could also make What do you think? I'm pretty hyped. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @kpervin, It's implemented! 🥳 There is now a plugin system in With this you can do things like this: import { makeSxStyles } from "tss-react/mui";
function TestSxComponent() {
const { classes } = useSxStyles();
return (
<div className={classes.root}>
Should look like: https://mui.com/material-ui/react-box/#the-sx-prop
</div>
);
};
const useSxStyles = makeSxStyles()({
"root": {
"width": 300,
"height": 300,
"backgroundColor": 'primary.dark',
'&:hover': {
"backgroundColor": 'primary.main',
"opacity": [0.9, 0.8, 0.7]
}
}
});And it ends up looking like this: Screen.Recording.2022-05-13.at.02.44.27.mov@mnajdova @oliviertassinari, I tag you along, I would love to have your feedback on this new feature. Best regards |
Beta Was this translation helpful? Give feedback.
-
|
We had some requests in MUI for using the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was playing around with a way to use the
sxprop syntax withmakeStyles(namely being able to use shorthands and breakpoint objects) with the following code for MUI:It seems to work, though it needs some optimization for better generated class names per component, and I'm unsure about how well it would work with SSR.
That being said, as it is possible, is there any chance we might be able to work this into a plug-in of some sort that allows
sxsyntax inmakeStyleswhen defining it fromtss-reactthrough providing the appropriate function from whatever librarytss-reactis being used with?Beta Was this translation helpful? Give feedback.
All reactions