Open giavinh79 opened 1 month ago
@giavinh79 Thank you for creating this issue! π The problem stems from the fact that this particular slot supports two ways of passing props:
In such case, to replicate/keep the existing behavior you need to use resolveComponentProps
to avoid the TS errorβand a problem if you'd use a callback in your example.
Please find the updated demo and let me know if you have any further questions regarding this. π π
@flaviendelangle do you agree that we should improve the documentation in this regard? π€ The question is, would it make sense to extend https://mui.com/base-ui/guides/overriding-component-structure/ or create a separate page in X documentation?
This relates a lot to https://mui-org.slack.com/archives/C04U3R2V9UK/p1714135691643129?thread_ts=1714088113.295129&cid=C04U3R2V9UK
base-ui
is dropping the slots approach (but @mui/material
will keep using it) so the guide might not survive for very long in its current form.
Let this be the issue that we can use as a basis to improve the documentation. I'm moving it to grooming. π
Steps to reproduce
https://codesandbox.io/p/sandbox/mui-slotprops-types-8v6mfz?file=%2Fsrc%2FDemo.tsx%3A8%2C1
Steps:
sx
propCurrent behavior
Type errors on
sx
propExpected behavior
sx
prop has types and intellisenseContext
Currently on V6 of
@mui/x-date-pickers
(but issue can be reproduced on latest version of MUI as well) and creating a component wrapping the MUIDatePicker
andDateRangePicker
components.The custom component may have
sx
styles defined internally viaslotProps
but should allow a consumer to override these styles. Thecodesandbox
has a basic example of this but as you can observe, there are type errors on thesx
prop inslotProps
.Your environment
MacOS Sonoma Chrome Version 125.0.6422.61
Search keywords: sx slotProps typescript DatePicker custom