小编max*_*any的帖子

使用自定义字体全局覆盖 Material UI 5.0 版式主题

Material Ui 5.0我目前正在尝试使用两种个人字体。我想通过覆盖theme. 我的第一个问题是我什至无法正确加载字体,而且我typography根本无法更改字体。此外,使用 时MUI 5.0,我无法将此自定义字体应用于全身部分。因此,如果使用 <Typography variant='h4'>. or <Box>...</Box>我的自定义字体则不适用。我在版本 5 中进行全局覆盖的方式Mui 4.0不再起作用。我很恼火,因为它MUI 5.0 documentation没有正确或根本解释不了这一点,而且我已经坐在那里几个小时了。

我将不胜感激任何帮助 !

我在用React, Typescript

字体.d.ts

 declare module '*.woff'
 declare module '*.ttf'
Run Code Online (Sandbox Code Playgroud)

CSSBaseLine.ts

import CustomOneMediumWoff from '../fonts/CustomOne-Medium.woff'
import CustomOneTwomWoff from '../fonts/CustomOne-Twom.woff'

    export const CssBaseline = {
        MuiCssBaseline: {
          
            // '@global': {
            //     html: {
            //       fontFamily: 'CustomOneTwomWoff',
            //       height: '100%',
            //       overflow: 'auto',
            //     },
            //     body: {
            //       fontFamily: 'CustomOneTwomWoff',
            // …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs material-ui

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

material-ui ×1

reactjs ×1

typescript ×1