-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[CssVarsProvider] Add CssVarsProvider in @mui/material #31138
[CssVarsProvider] Add CssVarsProvider in @mui/material #31138
Conversation
@material-ui/core: parsed: +2.26% , gzip: +2.44% |
resolveTheme: (theme) => { | ||
const newTheme = { | ||
...theme, | ||
typography: createTypography(theme.palette, theme.typography), | ||
}; | ||
|
||
return newTheme; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolveTheme: (theme) => { | |
const newTheme = { | |
...theme, | |
typography: createTypography(theme.palette, theme.typography), | |
}; | |
return newTheme; | |
}, |
From what I checked in createTypography
, there is no need to recalculate here. Developer can customize the typography via experimental_extendTheme
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can, as the typography is being generated by the palette, which based on the colorScheme
set on the CssVarsProvider is being calculated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let's keep it like this but I think we should be able to remove it in the future. In createTypography.js
, I don't see any usage of the palette internally. With the CSS variables, I don't see a need to accept typography as a function because developers can use the palette via CSS variables.
extendTheme({
typography: {
h1: {
color: 'var(--joy-palette-text-primary)',
}
}
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Left a few comments. I'm excited!
@siriwatknp @danilo-leal I've created this PR for adding documentation around the CSS variables - mnajdova#32 |
I suggest to merge the implementation first because I feel that the doc would require some time to be finished. |
Yup, agree with that! Pretty cool experimentation here though, curious to see how we're going to evolve with this in Material UI. |
I think the next step could be asking the community to help us update each component to support CSS variables (similar to the v5 transition #24405). Write some announcement blog post, docs. |
Alright then, I will revert the changes in the DemoSandbox and merge this one |
…com/mnajdova/material-ui into feat/css-vars-provider-mui-material
Question on css theme variables for MUI - this issue notes the feature as experimental. Are there plans documented anywhere for the feature to become....not....experimental? :) |
We are in the process of stabilizing the API in #40225 |
Preview - https://deploy-preview-31138--material-ui.netlify.app/experiments/material-ui/css-variables/
TODOs:
DemoSandboxed