mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.32k stars 32.12k forks source link

[Icon] Font size is not applied to Material font icons #29689

Open pmasior opened 2 years ago

pmasior commented 2 years ago

Duplicates

Latest version

Current behavior 😯

Set component props as for example fontSize="small" or sx={{ fontSize: 30 }} don't modify size of icon. It doesn't work for Material Icons. Change font size for FontAwesome icons works correctly.

obraz

obraz

Expected behavior 🤔

Icon size should be changed after set fontSize="small" or sx={{ fontSize: 30 }}

Steps to reproduce 🕹

Steps:

  1. Go to https://mui.com/components/icons/#font-material-icons
  2. See that icon size is not changed for the two last icons

Context 🔦

I tried to insert icon and change its size using component

Your environment 🌎

  System:
    OS: Linux 5.13 Linux Mint 20.2 (Uma)
  Binaries:
    Node: 16.13.0 - /usr/bin/node
    Yarn: Not Found
    npm: 8.1.0 - /usr/bin/npm
  Browsers:
    Chrome: 95.0.4638.69
    Firefox: 94.0
  npmPackages:
    @emotion/react: ^11.5.0 => 11.6.0 
    @emotion/styled: ^11.3.0 => 11.6.0 
    @mui/core:  5.0.0-alpha.54 
    @mui/icons-material: ^5.0.4 => 5.1.0 
    @mui/lab: ^5.0.0-alpha.54 => 5.0.0-alpha.54 
    @mui/material: ^5.0.4 => 5.1.0 
    @mui/private-theming:  5.1.0 
    @mui/styled-engine:  5.1.0 
    @mui/system:  5.1.0 
    @mui/types:  7.1.0 
    @mui/utils:  5.1.0 
    @mui/x-data-grid: ^5.0.0-beta.7 => 5.0.0-beta.7 
    @types/react: ^17.0.30 => 17.0.34 
    react: 17.0.2 => 17.0.2 
    react-dom: 17.0.2 => 17.0.2 
    typescript: ^4.4.4 => 4.4.4 
watanabeshuji commented 2 years ago

@DukeManh me too. but I found this workaround. (v5.2.5)

NOT work

<Icon sx={{ fontSize: 18 }}>show_chart</Icon>

work

<Icon style={{ fontSize: 18 }}>show_chart</Icon>
pmasior commented 2 years ago

@DukeManh me too. but I found this workaround. (v5.2.5)

NOT work

<Icon sx={{ fontSize: 18 }}>show_chart</Icon>

work

<Icon style={{ fontSize: 18 }}>show_chart</Icon>

Thanks for your answer. This workaround works in my case

mikew commented 2 years ago

I'm able to set it at a theme level with

  components: {
    MuiIcon: {
      styleOverrides: {
        fontSizeInherit: () => ({
          fontSize: 'inherit !important',
        }),
        fontSizeSmall: ({ theme }) => ({
          fontSize: `${theme.typography.pxToRem(20)} !important`,
        }),
        fontSizeLarge: ({ theme }) => ({
          fontSize: `${theme.typography.pxToRem(36)} !important`,
        }),
      },
    },
  },

But this seems ridiculous to have to do

IonVillarreal commented 1 year ago

Hi, any news on this problem?

hayyaun commented 1 month ago

Hi, any news on this problem?

Hi, I still see this issue in the latest version. "5.16.6"