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

Ben*_*der 1 javascript fonts reactjs 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,
  }
});
Run Code Online (Sandbox Code Playgroud)

这是我目前用于更改字体和一些版式属性的内容。但我需要更改标题的字体。有谁知道如何做到这一点?

Mat*_*att 5

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

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