-
-
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
Ability to override additional props in every MUI Components #38986
Comments
The workaround is to create a new component using
But I don't want to have a separate component while it's possible to do by overriding component. |
I looked at the source code and I was wondering how to effectively use I changed
Basically, I introduced
TypeScript was happy with it. |
I'm not sure if there's a way already to use |
I'm pretty sure it's not only myself who wants this. I was doing some research and found this StackOverflow question without an answer. |
@ever-dev You are applying the variant incorrectly which you showed in the description. Follow this documentation on how to create a new component variant. See - https://codesandbox.io/s/thirsty-mcnulty-r4tmlf?file=/src/App.tsx. There's a TypeScript error because we don't provide the interface As for your question, if you want to have your own props you will have to create a new component wrapping the Material UI component. |
@ZeeshanTamboli |
You can create your own wrapper component and extend the Material UI's interface with your custom interface for types. Why not this? Can you provide your use cases examples in the form of CodeSandboxes so that we are one the same page? The issue template is a good starting point. |
Im having a similar issue in Ive also tried module augmentation on the
Is there any reason that the above wouldnt work? Its an exported interface so I assumed there wouldnt be any issues |
@mogrady88 Does this work for you - https://codesandbox.io/p/sandbox/white-wave-fxqrlq?file=%2Fsrc%2FApp.tsx%3A44%2C2? |
That gets me a lot closer. I think I can come up with the rest based off of your example. Thank you! |
Actually @ZeeshanTamboli using
|
@mogrady88 I am not quite understanding you. It would be better to provide a CodeSandbox. Have you added the function CustomTab(
props: TabProps<"div", { dense?: boolean; external?: boolean }>
...
... CodeSandbox - https://codesandbox.io/p/sandbox/white-wave-fxqrlq?file=%2Fsrc%2FApp.tsx. |
I can do that but I shouldnt have to. Here is a codesandbox that shows the issue.
You only have to pay attention to |
There are also other missing types. Im getting reports that the I will be out of town for the next few weeks but Ill check this thread when Im back in office. Thank you for your help in this matter! |
@mogrady88 To enable the CodeSandbox link: https://codesandbox.io/p/sandbox/shy-lake-rjnvdr?file=%2Fsrc%2FApp.tsx%3A49%2C7 |
Duplicates
Latest version
Summary 💡
I want to add new props to MUI components without getting TypeError.
Examples 🌈
No response
Motivation 🔦
I wanted to add a border to the InputAdornment component with the
showBorder
prop.I tried to add
And used
It shows the border in the application, but TypeScript compiler throws an TypeError that
showBorder
doesn't exist.The text was updated successfully, but these errors were encountered: