-
-
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
[docs][material-ui] Improve theme.applyStyles()
docs
#44658
Conversation
6a340d7
to
c68a51b
Compare
* ``` | ||
* | ||
* @example | ||
* 2. using with `sx` prop: | ||
* ```jsx | ||
* <Box sx={theme => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work, sx prop doesn't accept (theme) => array
as styled does.
bb63799
to
557a511
Compare
theme.applyStyles()
docs
@@ -229,18 +229,29 @@ import Button from '@mui/material/Button'; | |||
</Button>; | |||
``` | |||
|
|||
### Codemod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section wasn't removed, it was just moved below
Co-authored-by: Sycamore <71297412+samuelsycamore@users.noreply.github.com> Signed-off-by: Diego Andai <diego@mui.com>
We discussed @siriwatknp's review directly, and I applied the agreed changes. |
Closes #44488
Preview for changed pages is here: #44658 (comment)
Add docs to address the four concerns raised in #44488:
Sx and Styled can't override styles that use
theme.applyStyles
due to specificity-> Add specificity warning and example
theme.applyStyles
doesn't support template literal syntax so the css selector has to either be extracted to a var or hardcoded-> Add section explaining how to override
theme.applyStyles
to cover this and any other custom caseDocs are inconsistent on recommendations. Docs say to use spread syntax on
theme.applyStyles
, then the actual code files say to not use spread syntax. ie. Docs, Code-> Use same convention in docs as in code source
applyStyles isn't a valid replacement for controlling the theme of specific components. If you only specify dark theme styles with applyStyles, then adding
.mode-light
to a component won't apply those styles since.mode-dark
has higher specificity. Refer to link for example-> Can be covered following the override
theme.applyStyles
section