我有一个与Can't override root styles of Typography from Materil-UI类似但不同的问题
在v4中我有一个主题:
import { createTheme } from '@material-ui/core/styles';
export const theme = createTheme({
palette: {
type: 'light'
},
typography: {
fontFamily: ['Work Sans', 'sans-serif'].join(','),
fontSize: 14,
h1: {
fontFamily: ['Rubik', 'sans-serif'].join(','),
fontSize: 20
},
h2: {
fontFamily: ['Rubik', 'sans-serif'].join(','),
fontSize: 18
},
h3: {
fontFamily: ['Rubik', 'sans-serif'].join(','),
fontSize: 16
},
h4: {
fontFamily: ['Rubik', 'sans-serif'].join(','),
fontSize: 16
}
}
});
这很好地覆盖了<Typography variant='h2'>h2 heading</Typography>
的字体大小
在升级到v5时,此覆盖不再起作用
我还尝试添加一个组件部分的主题
components: {
MuiTypography: {
styleOverrides: {
h2: {
color: 'red',
fontSize: '18px'
}
}
}
}
这也行不通。
我注意到,HTML中添加了一个新类,它覆盖了以前所有的CSS
需要什么才能根据v4覆盖所有版式变体?Extra class added这不是v4 HTML中的内容
3条答案
按热度按时间imzjd6km1#
使用样式覆盖,可以覆盖变量,如下所示:
这对我很有效,希望对你有帮助:)
s2j5cfk02#
在
app.ts
中我有本该如此
ffvjumwh3#
我做了上面的,仍然没有改变。只有当我也删除了我的package.json中的任何MUI V4引用时,它才为我整理出来。希望这对某人有帮助:)