有没有办法使用材料ui @next React在Typography中为不同的属性添加不同的字体

时间:2018-02-06 20:38:34

标签: javascript reactjs fonts material-ui

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,
  }
});

以下是我目前用于更改字体和某些“版式”属性的内容。但我需要更改标题的字体。有谁知道怎么做?

1 个答案:

答案 0 :(得分:3)

您可以在每个Typography-variant基础上覆盖fontFamily:

const theme = createMuiTheme({
  typography: {
    fontFamily: 'forzaBook',
    caption: {
      fontFamily: "sans-serif"
    }
  },
});