-
-
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
[material-ui] Add mergeSlotProps
for extending components
#44809
Conversation
Netlify deploy preview@material-ui/core: parsed: +0.07% , gzip: +0.07% Bundle size reportDetails of bundle changes (Toolpad) |
Co-authored-by: Sycamore <[email protected]> Signed-off-by: Siriwat K <[email protected]>
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.
Thanks for working on this @siriwatknp. I think it will be very useful now that we're standardizing the slots pattern.
Yes, this PR will be used by some Material UI components too, e.g. a |
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.
LGTM
From #44350 (comment).
Docs: https://deploy-preview-44809--material-ui.netlify.app/material-ui/guides/composition/#forwarding-slot-props
Without the function, a lot of boilerplate code is required. I believe that users will create this kind of utility in their codebase because it's quite a common use case to extend Material UI components, so I think we should provide this utility called
mergeSlotProps
.The
mergeSlotProps
resolves function type and then merge the props. Only theclassName
that's concatenated to preserve the same behavior ofslotProps
, the rest will override the default ones. The usage is added to the docs.