我正在使用createMuiTheme
Material UI 设置自定义我的主题。如何为标题、正文和按钮标签设置特定字体?
我假设它将自定义主题中的排版组件。然后从 App 组件中选择它。但是找不到任何关于此的文档。
主题文件:
import { createMuiTheme } from "@material-ui/core/styles";
export default createMuiTheme({
typography: {
fontFamily: ["campton-book", "campton-light", "campton-medium"].join(",")
//something here setting specific font family for specific tags?
}
});
import React, { Component } from "react";
import PropTypes from "prop-types";
import { withStyles, MuiThemeProvider } from "@material-ui/core/styles";
import Typography from "@material-ui/core/Typography";
import Theme from "../Theme";
const styles = theme => ({
root: {
flexGrow: 1
}
});
class Tools extends Component {
render() {
const { classes } = this.props;
return (
<MuiThemeProvider theme={Theme}>
<Typography variant="h2">Some text here as h2 and the "campton-light" font family</Typography>
<Typography variant="body1">Some text here as body1 and the "campton-book" font family</Typography>
<Typography variant="overline">Some text here as overline and the "campton-medium" font family</Typography>
</MuiThemeProvider>
);
}
}
Apps.propTypes = {
classes: PropTypes.object.isRequired
};
export default withStyles(styles)(Apps);