-
-
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
Apply defaultProps
from theme to root styled
component
#34539
Comments
Thanks for the examples and detailed explanation. I would wait to see if issue gets more traction before adding overhead to the default styled() utility, mainly because it's use in all components and it could add unnecessary overhead. |
I'd like to bump this as well. We're converting from |
Please assign this issue to me |
Just some thoughts here, |
This issue relates to the theme properties called |
Is there any new information regarding this issue? |
Duplicates
Latest version
Summary 💡
defaultProps
defined under a custom component name should be picked up and applied bystyled
component, even if it required a setting within thestyled
function call. Currentlyvariants
andstyleOverrides
inside the theme can be referenced and used bystyled
components and are configurable using some of its options,.Perhaps a setting like this to allow handling some of MUI's use-cases
or just a boolean parameter which enables or disables the
styled
component from accessingtheme.components[name].defaultProps
Examples 🌈
The following custom component
With the following theme definition
and rendered like this
will NOT have its
variant
prop be set tooutlined
. Instead, by referencing some MUI components we see thatuseThemeProps
is needed to extract thedefaultProps
from thetheme
.This wrapper component is usually where classNames are generated and more complex components compose all their
styled
sub components. So it's only natural for Mui core components to require these defaults though theuseThemeProps
before the style component is even rendered.Motivation 🔦
Having to wrap each custom component just to call a hook which passes a key we're already feeding into the
styled
component feels very redundant. Not to mention it adds to boilerplate for typescript and ref usage. Our projects share a base theme with custom properties and some customstyled
components are also registered using thetheme.components
object. It would be very helpful to give each theme override a different set ofdefaultProps
for our custom components.The text was updated successfully, but these errors were encountered: