-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Icons should not have hardcoded font size, it prevents them from scaling with text #11493
Comments
@jedwards1211 We have been doing some back and forth on this point in the past: #10349.
The point is that you can apply a font size instead of changing the width and the height.
This is a tradeoff. We follow the same one than the material font icons set: https://fonts.googleapis.com/icon?family=Material+Icons ...
.material-icons {
...
font-size: 24px;
..
} Also, this is an important breaking change, something we don't want to introduce for the next 6 months+. Maybe we should add a property to the component: |
@oliviertassinari I like the component property idea. Considering that One problem: since both the |
@jedwards1211 Why would one have to pass the property on both? Shouldn't a user pick on approach, font vs svg and stick to it? |
@oliviertassinari oh...seems I thought I had to wrap my svg icons in |
@jedwards1211 I don't think that we document this pattern anywhere in the documentation. |
Expected Behavior
Icons (both the
<Icon>
and specific icon components like<ChevronRight>
) inherit their parent'sfontSize
so that they scale with the textCurrent Behavior
Icons have a hardcoded
fontSize
of24px
. This makeswidth: 1em
andheight: 1em
pointless, because the em square is fixed to the element's ownfontSize
of24px
instead of the parent's font size.Steps to Reproduce (for bugs)
In this example I have two icons inside of an
<h1>
withfontSize: 4rem
, and also inside of another<h1>
withfontSize: 3rem
. The first icon is default and fails to scale to the parent font size. The second icon has CSS overrides to produce the expected behavior.https://codesandbox.io/s/8n27qrv9q8
Workaround (in
theme.overrides
)Context
As seen in the example, I am using inline chevron icons as part of a breadcrumb component.
Your Environment
The text was updated successfully, but these errors were encountered: