Inverse font size from theme
See original GitHub issueThe font-size behaves the opposite way than in CSS and is not documented:
// Normal font-size
createMuiTheme({ typography: { htmlFontSize: 10 } });
// Expected 2x the previous font-size, instead got 0.5x
createMuiTheme({ typography: { htmlFontSize: 20 } });
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
The font-size depends on the property htmlFontSize
.
Current Behavior
The font-size is inversely proportional to the htmlFontSize
instead of directly proportional.
Steps to Reproduce (for bugs)
If YOU DO NOT take time to provide a codesandbox.io reproduction, should the COMMUNITY take time to help you? I am an OSS developer as well, I think the issue is explained quite clearly and this question is very condescending. I am contributing because I think it might improve material-ui long-term, not to get help.
- Set-up a theme with
htmlFontSize
of 10. - Contemplate its size.
- Change the
htmlFontSize
property to 20. - Marvel at how the text becomes smaller instead of larger.
Context
I was following the theme tutorial. Since there is no documentation on htmlFontSize
, the expected result is that it behaves similar to font-size
.
Your Environment
Tech | Version |
---|---|
Material-UI | 1.0.0-beta.36 |
React | 16.2.0 |
browser | any |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Inverse font size from theme #10579 - mui/material-ui - GitHub
Current Behavior. The font-size is inversely proportional to the htmlFontSize instead of directly proportional. Steps to Reproduce (for bugs).
Read more >How to reverse font size to original font in Windows 10?
How can I reverse the change? I tried going to control panel and clicking "restore default font" and it didn't work. Thank you!...
Read more >font-size inversely proportional to the screen size - CodePen
Want to change your Syntax Highlighting theme, Fonts and more? ... -03-23T20:23:00.000Z\",\"title\":\"font-size inversely proportional to the screen size\" ...
Read more >style_mono_accent_inverse: Monotone Accent Inverse Theme in ...
Code Text Font Size. Defaults to 0.9rem. Modifies the .remark-inline class. Accepts CSS font-size property values. The value of this variable is also...
Read more >Font Size Idea: px at the Root, rem for Components, em for ...
I'm gonna size everything with them, that way I can adjust the font-size on the root element and everything will scale with it!...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did read that bit 3-4 times beforehand and applied that before opening this. I even dug into the code, that is why I decided to open this! I do know a thing or two about CSS libraries. That bit of documentation seems to be saying “make the
font-size
of the html to62.5%
and don’t change that. Use thehtmlFontSize
instead as shown in this example”.So the documentation seems to be indicating exactly the opposite of what is happening, and that is why I opened this. I know material-ui uses rem so it’ll be dependent on the base html css and I’m using it like that on my project. But I didn’t know that until digging into the code and was really surprised of this behavior.
My recommendation would be to change the name of
htmlFontSize
to something visitors wouldn’t want to touch likehtmlFontDivisor
. Or at least document thathtmlFontSize
does not set thefont-size
(which is highly misleading). But don’t worry, won’t bother you again.@franciscop-invast I’m happy you raised this point. I believe you have proven with the issue that we should be more strict about this policy. The point is to ask people work upfront before they open an issue. So they think twice and have a closer look at the documentation.
If you would have spend more time upfront, you would have notice the following sentence in the documentation:
Now, I believe we need to improve the documentation. We can add a sentence about what’s this
htmlFontSize
key is for (maybe not what you are looking for, it’s the font size of the<html>
element).Regarding changing the font size, each typography elements has it’s own. You need to change each individually or hack the
htmlFontSize
purpuse to get a global increase. For instance, you could tell Material-UI the html font size is 14px while it’s 16px on the DOM. Material-UI will increase the rem value to compensate. Overall, all the font sizes will be uniformily increased.