【发布时间】:2019-01-22 13:58:19
【问题描述】:
所以,我已经阅读了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 元素的样式?
【问题讨论】:
标签: javascript html css reactjs material-ui