-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[RFC] Extend variants to support slots #28107
Comments
I think that it would be great to expand on the pain. For instance, maybe nested selectors in the theme is OK in most cases. I would also be curious to see the prior arts in the space. |
I started thinking about this as I saw complain that the styles overrides are not type safe (as both styled and the sx prop do not accept slots). My thinking was that we can at least make the theme variants type safe, so I wrote this idea in the RFC before I will move on something else and forget about it 😃 We can wait to see if this will resonate with the community and whether it is actually a pain worth solving. |
@siriwatknp FYI |
Starting with the pain :). What's the problem? Why is it worth a breaking change or if it's not breaking an API fragmentation? |
My purpose is to have one place to discuss which way we want to go (
I don't think this will cause a breaking change but deprecation is expected. |
I propose we close #27415 see #27415 (comment) and then this will be one place where we can discuss this. I don't think opening third issue will help. |
GoalDecide on one API between RequirementsLet's make sure that we have considered all possible use cases about theme customization so that we can pick the API that provides the best experience.
API
|
+1 for consolidating the API. I like better the What is important with this is that although the API is similar as before, there is an important change in the behavior (the keys here are slots, not a combination of props & slots as they were before). We MUST handle this breaking change and cover 100% of the migration of it, otherwise, developers won't be happy having to adjust the theme structure all over again. The same would go for the variants.
Regarding this, I hope it is like this, but I am not sure as we were recommending |
@siriwatknp would you like to close #28107 and #27415 and open a new issue for #28107 (comment) |
Sure, I am waiting to see other comments from the team if we are good with |
Closed in favor of #30412 (comment) |
This RFC is no longer needed because
theme.styleOverrides
supports already support variants in v6.The problem
In the theme we already have an API for adding custom style overrides for some combination of props. For example:
However, with the current setup, developers can only add variants for the root component. If they need to add overrides on some of the slots inside, they need to use class selectors, hence increase the specificity. For example:
The solution
In order to fix this, this RFC proposes we add a new additional property for each variant, call slot, that would indicate where these style overrides need to be applied. For example:
When we create the slot components, we already have the slots set, for example, this is the start icon slot of the Button component.
The change is not a breaking change and can be added at any moment. We can treat non setting slot as a
Root
as we did till now.Prio-arts
The text was updated successfully, but these errors were encountered: