-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[theme] Be able to use string templates inside createMuiTheme #18000
Comments
What you probably want is tagged template literals not just template literals. You would need to use an extra helper like root: css`
font-size: 14px;
color: ${props => props.theme.palette.text.primary};
` and even then would we need to run the string through a CSS parser. I don't think this is worth the effort but let's see what others think. |
Agee, this will likely be possible with styled-components. |
An update, this issue is being resolved in v5 thanks to #22342 and the new const theme = createMuiTheme({
components: {
MuiSlider: {
styleOverrides: {
root: css`
background-color: red;
`
}
}
}
}); https://codesandbox.io/s/continuousslider-material-demo-forked-9595u?file=/demo.tsx However, the usage of props isn't supported, so far, we aim to address the issue with the |
Closing for #15573. Developers can use the variant API to implement something similar. |
@mnajdova Actually, this makes me wonder. There is currently no way to dynamic render CSS in the theme based on the props. Is this something we need? |
We have this ability with the variants API as you've mentioned. As far as I remember from our discussions before, we still support the |
Interesting. A couple of thoughts:
|
I don't understand why the variants API is a hack. As far as I remember we had discussion around adding I am ok with restructuring that |
One more thought, if we support props in the |
@mnajdova Sounds good, I think that it's a topic for v6 or v5.x. We can wait, see how things settle once v5 is out. |
Be able to use string templates when you use createMuiTheme and you want override a component like MuiButton :
..with jss-plugin-template plugin :
++ Unify style with the same structure as I can do inside "makeStyles" or "withStyles".
++ Use global props defined inside theme
The text was updated successfully, but these errors were encountered: