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] Revise "Component theming" and "How to customize" guides #31997
[docs] Revise "Component theming" and "How to customize" guides #31997
Conversation
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
|
||
`sx` is also compatible with theme style overrides if you prefer the shorthand notation. | ||
Note that some components expose a `color` prop, which has a lower specificty than the theme's styles overrides. For example, say you have customized `Link`'s color. |
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.
@danilo-leal I was wrong. The Link
is actually a bug. This should have the highest priority <Link color="highest-priority-color">...</Link>
.
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.
You can remove this part and I will create a fix in a separate PR.
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.
Makes sense! I was just thinking it was weird for the component color prop to have lower specificity... I'll correct this sentence!
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.
@siriwatknp are you going to bump the specificity for each prop combination? Should we create an RFC for this and make it work consistent with Material UI? In this case, when would you ever need the props callback?
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.
@mnajdova I am not sure I follow you. From my understanding, this is a bug on the Link component.
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.
I would say that the Typography (and Link) are basically the ones that work differently, in the other components that theme overrides take precedence, for example take a look at the button - https://codesandbox.io/s/shy-dust-sdylec?file=/src/App.tsx
Co-authored-by: Siriwat K <siriwatkunaporn@gmail.com>
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.
Solid improvements! I've just gone through how-to-customize
and will come back to theme-components
in the morning!
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
|
||
Using the `styled()` utility offers a simple way for adding dynamic styles based on props. | ||
> ⚠️ Note that if you are using TypeScript you will need to update the prop's types of the new component. |
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.
> ⚠️ Note that if you are using TypeScript you will need to update the prop's types of the new component. | |
> ⚠️ Note that if you are using TypeScript you will need to update the prop types of the new component. |
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.
I feel like we should move this back right before the demo showing how it should be altered in TypeScript.
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.
Before or after? Haven't altered its position, its in the same spot as in the current version.
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
|
||
If you are not familiar with the `sx` prop, make sure you first check out [the concept around it](/system/the-sx-prop/) and [the difference with the `styled` utility](/system/styled/#difference-with-the-sx-prop). | ||
|
||
To have a similar shorthand CSS notation to the `sx` prop but within the theme, you can use `sx` inside the `stylesOverrides`. |
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.
Rephrasing.
To have a similar shorthand CSS notation to the `sx` prop but within the theme, you can use `sx` inside the `stylesOverrides`. | |
You can use the `sx` prop inside the `styleOverrides` key to modify styles within the theme using shorthand CSS notation. |
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.
Can we elaborate on why a developer would want to do this? And this would also be a good place to explain why this is "experimental."
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.
@mnajdova anything you'd like to share about that?
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.
Can we elaborate on why a developer would want to do this?
Mainly for conistency. If a developer is already used to the sx
syntax and it's shorthands, it's limiting that it can be used on only one place (the sx
prop). More over, if they want to convert from sx
prop to styled()
, or move the styles to the theme overrides, they would have to manually change the styles to comply with the other regular syntax. This utility helps them by doing it automatically and providing a better DX along the way.
It's experimental as it was added after the v5 stable release, and we usually export API like this as an experimental first, to see if there will be some unforeseen bugs and stabilize them later.
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.
Let me know what you think, tackled these aspects.
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
@siriwatknp & @mnajdova little bump in your notifications to get this one out! |
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.
👍 Thanks for improving these important pages!
|
||
Let's go back to the above demo. How can you override the slider's thumb? | ||
<img src="/static/images/customization/dev-tools.png" alt="dev-tools" width="796" style="margin-bottom: 16px;" /> |
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.
The change of docs/public/static/images/customization/dev-tools.png looks blurry on my screen. Am I the only one? I mean:
a. https://mui.com/customization/how-to-customize/#overriding-nested-component-styles
b. https://deploy-preview-31997--material-ui.netlify.app/customization/how-to-customize/#the-sx-prop
a. looks better on my end. I'm raising this because it's not the first time I see this problem. What do you think of limiting the resolution to x2, would it solve the problem? Otherwise, could we try a fixed integer increment? Currently, we are doing x3.28, maybe x3 or x4 would look crisp?
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.
Huh... looks a bit blurry to me too, now that I'm looking at it again. But I did export at 2x (don't know where you got x3.28 from!). Though the blurriness could be because I increased the image size a bit. Let me see if I can tweak it properly.
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
|
||
⚠️ These class names can't be used as CSS selectors because they are unstable, | ||
however, MUI applies global class names using a consistent convention: `Mui[Component name]-[name of the slot]`. | ||
First, use your browser's dev tools to identify the class for the component slot you want to override: |
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.
I think that it was clearer before. We were explaining how to "identify the class" in logical order. How will people know that MuiSlider-thumb
is the right selector when all they see is?
We do no longer explain it in the flow, but at the bottom of the section. I think that it requires developers to do back and forth to understand the whole process, which is not ideal.
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.
You're right. Revisited this one now, let me know your thoughts.
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
…to-customize-revision
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/how-to-customize/how-to-customize.md
Outdated
Show resolved
Hide resolved
docs/data/material/customization/theme-components/theme-components.md
Outdated
Show resolved
Hide resolved
Commenting to bump this one up in y'all notifications! |
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.
I thought I had already approved it 😂.
This header was changed in #31997, but it doesn't seem to need to be a h3, h2 seems enough, and retain the anchor link Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Took the liberty to revise some of this content, which I think are some of the most important in the docs. There were some general reorganizing opportunities that I found and some content optimization (excluding something mentioned twice). All of it was inspired by this issue, given we weren't mentioned about
sx
prop higher than the theme's styles overrides specificity.Initially, I was only going for the "How to customize" page but ended up thinking that the best place to tackle the issue above was in the "Component theming" page instead. So, since I was there already, took the opportunity to go through it as well.
Please revise the accuracy of the rewritten content!
Deploy previews: