question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MaterialUI Icon fontSize overwrriten by Materialicons font CSS when using injectFirst

See original GitHub issue

I am using injectFirst so I can overwrite some MUI styles in my stylesheets. The problem is that the .material-icons class from https://fonts.googleapis.com/icon?family=Material+Icons now overwrites the CSS that <Icon fontSize='small'> sets. So the font-size is always the 24px.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

.material-icons {} CSS overwrites the one generated my MUI for icons (such as font-size).

Expected Behavior 🤔

The Google MaterialIcons CSS is included before any changes made by MUI.

Steps to Reproduce 🕹

Steps:

  1. Use injectFirst on StylesProvider <StylesProvider injectFirst>.
  2. Include Material Icons in your CSS (head):
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
  3. Use an Icon component and try to change the size: <Icon fontSize='small'>help</Icon>.
  4. The fontSize is still the initial 24px from the .material-icons CSS class.

Context 🔦

Your Environment 🌎

Windows 10, Chrome 80.

Tech Version
Material-UI v4.9.3
React v16.2
Browser Chrome 80
TypeScript 3.7.5

I don’t have a perfect solution for , maybe injectFirst should somehow only inject after the MUI CSS dependencies.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Mar 24, 2020

@Cristy94 We document alternatives to the HTML comment.

1reaction
Cristy94commented, Mar 6, 2020

I just now tried your solution and it worked. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

MaterialUI Icon fontSize overwrriten by Materialicons font CSS ...
I am using injectFirst so I can overwrite some MUI styles in my stylesheets. The problem is that the .material-icons class from ...
Read more >
Change MaterialUI icons font size in css - Stack Overflow
MaterialUI icons use the default size 24px . If you want to change this size without using the icons size classes provided by...
Read more >
Icon API - Material UI - MUI
Learn about the props, CSS, and other APIs of this exported module. ... class that suits the icon font you're using (e.g. material-icons-rounded,...
Read more >
@material-ui/icons | Yarn - Package Manager
This package provides the Google Material icons packaged as a set of React components. Installation. Install the package in your project directory with:...
Read more >
Icon Fonts — Vuetify
Vuetify is a Material Design component framework for Vue.js. ... with support for Material Design Icons, Material Icons, Font Awesome 4 and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found