Repository navigation
[doc] Add differences between styled and sx - #28685
Conversation
mnajdova
left a comment
There was a problem hiding this comment.
Looks great, left some feedback to address. Let me know what you think!
I will need to investigate this further, but it seems like it may come from this line: https://github.com/mui-org/material-ui/blob/master/packages/mui-system/src/createStyled.d.ts#L20 (which is needed for supporting the nested selectors as far as I remember). |
Co-authored-by: Marija Najdova <mnajdova@gmail.com>
|
I've tried to bring some improvements, let me know if that's better. I've added infos about the theme because that's not obvious either |
mnajdova
left a comment
There was a problem hiding this comment.
I've applied some small changes, the content itself looks good to me. Let's wait for @mbrookes review and we can merge. Thanks a lot for the contribution @eric-burel 🙏
| }) | ||
| // Note: for direct theme access without modification, you can also use a shortcut by providing the key as a string | ||
| const MyStyledButton = (props) => ( | ||
| <button sx={{backgroundColor: "primary.main"}}> |
There was a problem hiding this comment.
Just curious - do host elements (lowercase button) accept an sx prop?
See #28678
This PR explains the difference between
sxandstyled.Note: there is also an underlying issue, because it seems to me that TypeScript currently doesn't catch when you use
mxor similar shortcuts intostyled, while it shouldn't accept those.