相关疑难解决方法(0)

如何使用Material-UI将排版主题默认应用于常规标签?

所以,我已经阅读了https://material-ui.com/style/typography/,我正在加载Roboto字体.我期待一个简单的组件,如:

const theme = createMuiTheme();

const App = () => {
  return (
    <MuiThemeProvider theme={theme}>
      <CssBaseline />
      <p>Hello world!</p>
    </MuiThemeProvider>
  );
};
Run Code Online (Sandbox Code Playgroud)

将使用Roboto(默认字体)设置p标签的样式.但这不会发生.如果我将代码更改为:

const theme = createMuiTheme();

const App = () => {
  return (
    <MuiThemeProvider theme={theme}>
      <CssBaseline />
      <Typography>Hello world!</Typography>
    </MuiThemeProvider>
  );
};
Run Code Online (Sandbox Code Playgroud)

它按预期工作.插入p标签以及排版css.我对如何使用库感到困惑:

  1. Material-UI的想法是我要用自定义的React元素替换所有常规的html标签吗?
  2. 有没有办法轻松地将主题排版中的样式应用到常规的html标签,如h1-6,p等?
  3. 我是否希望在某些顶级组件上使用withStyles自行设置所有常规html元素的样式?

html javascript css reactjs material-ui

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

标签 统计

css ×1

html ×1

javascript ×1

material-ui ×1

reactjs ×1