所以,我已经阅读了https://material-ui.com/style/typography/并且我正在加载 Roboto 字体。我希望有一个简单的组件,如:
const theme = createMuiTheme();
const App = () => {
return (
<MuiThemeProvider theme={theme}>
<CssBaseline />
<p>Hello world!</p>
</MuiThemeProvider>
);
};
将使用 Roboto(默认字体)设置 p 标签的样式。但这不会发生。如果我将代码更改为:
const theme = createMuiTheme();
const App = () => {
return (
<MuiThemeProvider theme={theme}>
<CssBaseline />
<Typography>Hello world!</Typography>
</MuiThemeProvider>
);
};
它按预期工作。插入了 p 标签以及排版 css。我对图书馆的使用方式感到困惑:
- Material-UI 的想法是我要用自定义 React 元素替换所有常规 html 标签吗?
- 有什么方法可以轻松地将主题排版中的样式应用到 h1-6、p 等常规 html 标签中吗?
- 我是否希望自己在某个顶级组件上使用 withStyles 来设置所有常规 html 元素的样式?