-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[pickers] DatePicker theme augmentation styleOverrides
types not working
#9969
Comments
Those I'm not sure |
Thank you for opening this issue. 🙏 This is somewhat of a breaking change, hence, we did not rush with a solution for it on our end. |
@alexfauquette would you agree that not having |
styleOverrides
types not working
Yes but I don't have a strong opinion on |
A better solution is to have |
Thank you for your suggestion. We are aware of the problem that users are facing in deciding the best way to tackle styling overrides in certain situations. In the meantime, could you clarify, which part of the pickers are you having problems styling? MuiPickersDay: {
styleOverrides: {
today: {
backgroundColor: 'yellow',
}
}
} This would apply the styling to all the (Date and Date Time) pickers variants in the application. |
I was trying to style the input, so like the border color & width, and font color. The interactive demo sounds like a cool idea btw 👍🏻 |
That's a use case that we haven't though of. As far as I can see, we do not have any unique classes or slots that would allow us to target specific pickers' text field. 🤔 |
The Otoh, perhaps it's not such a bad idea to target generic subcomponents instead, just in case we need an additional component that also uses it. |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/mui-x-issue-template-forked-9l2w87?file=/src/App.tsx
Steps:
root
root
using intellisenseroot
Current behavior 😯
The object
root
in the above example appears to be unknown, but is allowed typings-wise. It's unknown, and therefor hovering it reveals typescript thinks it's just an ordinary empty object. Pressing Ctrl+Space onroot
reveals why - it's not in the typings:And neither is any other child member of
styleOverrides
. This makes it near-impossible to know what I can do there. It's essentially as "blind" as plain Javascript.Furthermore, hovering the
styleOverrides
object reveals its type:So it says
Partial<OverridesStyleRules<never, "MuiDatePicker", Omit<Theme, "components">>>
- I'm pretty sure thatnever
isn't supposed to be in there, as it also isn't there for regular MUI components, like I dunno,MuiInput
.And as a result, I can do pretty much anything in
styleOverrides
and none of it will show any errors, i.e. no type checking is being done, because probably the types aren't there. I can add afoo
next toroot
, or abackgroundColor: 4
and it's all "good", because it doesn't check any of it. When I do the same for anMuiInput
theme, it's all type-checked perfectly, and none of my shenanigans is accepted.Expected behavior 🤔
That
never
probably shouldn't be there, and intellisense should work. Type checking should also work, it shouldn't allow unknown or incorrect things instyleOverrides
.Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
Order ID or Support key 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: