You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can see the difference between the two Example components, where one has its overridesResolver explicitly implemented.
Context 🔦
I'm making various components that I would like to be easily customizable globally, just like the ones Mui provides. This would be easier if style overrides were automatically applied.
Good catch, it applies only for the variants, we depend on the overridesResolver being added for the styleOverrides. I will update the documentation now.
@mnajdova since variants seem to have recently been deprecated in favor of passing callbacks in styleOverrides, is there a more correct way to do what you did for Example1 there?
I realize I can wrap my own styled() function with a default overridesResolver, but maybe it could be helpful if this was default behavior?
We are not 100% sure that variants will be out, we just reverted the deprecations, so that we don't set a wrong impression until we are certain about the API changes. In my opinion, as we already support callback in the style overrides, using styleOverrides as callback and adding the overridesResolver is the best option.
The variant API is not out yet, as it encourages more declarative way of defining style overrides, similarly to how designers would define them and Figma, and is much better suited for low code tools. See #30412 (comment) for more details.
We could automate the adding of the style overrides based on the slot root, for example adding the root styles on the Root slot, the icon styles to the Icon slot etc. We haven't done it so far, because we anyway need to add the overridesResolver to support all classes keys we have since v4. I will create an RFC on this and link this issue so that you can track the progress on it.
Duplicates
Latest version
Current behavior 😯
The example div should have a red background. Instead, it is blue, as the style override was not applied.
Expected behavior 🤔
According to the docs for styled() on this page, the
options.slot
property has the following description:options.slot (string [optional]): If Root, it automatically applies the theme's styleOverrides & variants.
If I provide {name: "Example", slot: "Root"} my style override should automatically be applied (for root, I assume)
Steps to reproduce 🕹
Code sandbox: https://codesandbox.io/embed/crazy-http-gtnyp0?fontsize=14&hidenavigation=1&theme=dark
You can see the difference between the two Example components, where one has its overridesResolver explicitly implemented.
Context 🔦
I'm making various components that I would like to be easily customizable globally, just like the ones Mui provides. This would be easier if style overrides were automatically applied.
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: