-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Typography] text color not working in v6 + Pigment CSS #43278
Comments
I miss the migration docs for this. Using color prop with dot notation is not supported with Pigment CSS due to dynamic interpolation. Please use <Typography sx={{ color: "text.secondary" }}>Hello!!!</Typography> |
Thanks. I confirm it works with sx. Seems the issue is also present in mui code
|
Oh, wow thank you so much. Will open a fix soon. |
@siriwatknp can you expand on this?
From a DX perspective I'd expect to be able to use the same notation everywhere a color is expected. |
Just to be clear, is this expected in your opinion At the moment, we should separate between color prop and sx color. color prop: it does not represent an exact value of CSS sx color: this refers directly to CSS |
Another option is to add export const TypographyRoot = styled('span', {
name: 'MuiTypography',
slot: 'Root',
overridesResolver: (props, styles) => {
const { ownerState } = props;
return [
styles.root,
];
},
})(({ theme }) => ({
margin: 0,
variants: [
…,
{ props: { color: 'text.primary' }, style: { color: theme.palette.text.primary },
{ props: { color: 'text.secondary' }, style: { color: theme.palette.text.secondary },
],
})); With this, it works with Pigment CSS and there is no need other internal usage of Anyway, I am fine with both of the options. |
@siriwatknp is this conceptually correct?
If that's the case, why did we support I think we should be consistent and intentional with this decision. I agree a variant ( |
@siriwatknp Maybe the issue is similar with "inherit". For example with https://next.mui.com/material-ui/react-link/ . It doesn't replace the color attribute too, seems the component is also based on typography |
Yes, that's what I perceive it at the moment.
I believe that the push (at the beginning of v5, even before I joined) was about system props instead of sx prop but it was partially done with some components (e.g. Typography, Link, Box, Grid). But things have changed and the direction we are pushing toward static generation with Pigment CSS does not work well with the system props, so I think that's the constraint to drop the system props.
Totally agree, that's why I think the |
|
@siriwatknp So I suppose it is a breaking change for V6, but it makes sense. Thank you ! |
It's not a breaking change for v6. It still works with the default Emotion engine but for opting-in to Pigment CSS, it will not work. |
Steps to reproduce
Link to live example: (required)
Steps:
Use pigmentcss
<Typography color="text.secondary">Hello!!!</Typography>
Current behavior
No secondary text color
Expected behavior
Secondary text color
Context
Also same issue with ListItemText and secondary prop because it uses typography
Your environment
npx @mui/envinfo
Search keywords: Typography text color not working
The text was updated successfully, but these errors were encountered: