-
-
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
Theme overrides do not work for classes defined for custom component in withStyles
#29018
Comments
Theming is flat out broken right now |
The workaround is to make the individual CSS properties dependent on the props, instead of the whole class object.
You only have to type the |
Hi, @oakhtar147,
|
Hi @Pablion,
Thanks. |
Thank you for the reply @oakhtar147,
|
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @oakhtar147 How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
I have a use case where I have defined classes for a custom component and inject those using the
withStyles
HOC. My classes depend heavily on theprops
passed to the component. However, I would also like to be able to override these classes using the globaltheme
'soverrides
object.Current Behavior 😯
Let me explain by showing the code:
This
Appbar
class is depending on thebackgroundColor
prop. That is why the class is a callback that returns the style object. Makes sense. I inject the classes like this:Now in global
theme
's overrides, I would like to be able to override this class. I will do it something like this:Unfortunately, this override will not work, and I will lose the styles that were defined in the component itself as well. If I remove the
prop
from the component class itself (making it independent of props) and a simple style object, the theme override works.The strange thing is that the callback function that returns the style object is never called if I have overrides defined for that class. That is why I would also lose the class defined within the component itself.
Expected Behavior 🤔
The overrides classes should override the component level class, regardless if the component level class is a props dependent callback that returns the style object, or the style object itself.
Using material-ui: ^4.12.3
The text was updated successfully, but these errors were encountered: