【问题标题】:Is there a way to add different fonts to different properties in Typography using material ui @next React有没有办法使用材料 ui @next React 将不同的字体添加到 Typography 中的不同属性
【发布时间】:2018-07-17 00:31:16
【问题描述】:
const fontWeightMedium = 500;
const theme = createMuiTheme({
  typography: {
    // Use the system font.
    fontFamily:
    'forzaBook',
    fontWeightMedium,
    body1: {
      fontWeight: fontWeightMedium,
    },
    button: {
      fontStyle: 'italic',
    },
    caption: {
      fontWeight:100
    }
  },
  palette: {
    primary: orange,
    secondary: {
      ...grey,
      // A400: '#00e677',
    },
    contrast: 'white',
    error: red,
  }
});

这是我目前用来更改字体和一些排版属性的方法。但我需要更改标题的字体。有谁知道怎么做?

【问题讨论】:

    标签: javascript reactjs fonts material-ui


    【解决方案1】:

    您可以根据每个排版变体覆盖 fontFamily:

    const theme = createMuiTheme({
      typography: {
        fontFamily: 'forzaBook', // Change the default
        caption: {
          fontFamily: "openSans" // Change a specific variant
        }
      },
    });
    

    【讨论】:

      猜你喜欢
      • 2012-04-18
      • 1970-01-01
      • 1970-01-01
      • 2013-02-19
      • 2022-12-07
      • 2021-11-02
      • 1970-01-01
      • 2017-02-10
      • 1970-01-01
      相关资源
      最近更新 更多