Material UI 5 学习04-Typography文本排版


一、Robo字体安装

提示:Material UI默认使用Robo字体,因此我们需要安装这个字体

yarn add @fontsource/roboto

二、使用介绍

示例:
在这里插入图片描述

import {Box, Typography} from "@mui/material";
function App() {
    return (
      <Box sx={{width:'100%',maxWidth:500}}>
            <Typography variant='h1' gutterBottom>
                h1. Heading
            </Typography>
          <Typography variant='h2' gutterBottom>
              h2. Heading
          </Typography>
      </Box>
    );
}

export default App;

gutterBottom的意思是给一个下边距。默认为false
variant的值有哪些呢?
在这里插入图片描述

可选地值还是很多的。h1-h6和css一致。
在这里插入图片描述
variant=‘subtitle1’ 副标题1
variant=‘subtitle2’ 副标题2

function App() {
    return (
        <Box sx={{width: '100%', maxWidth: 500}}>
            <Typography variant='h1' gutterBottom>
                h1. Heading
            </Typography>
            <Typography variant='subtitle1' gutterBottom>
                subtitle1. 副标题1,我的文章概要介绍
            </Typography>
            <Typography variant='subtitle2' gutterBottom>
                subtitle2. 副标题2,gutterBottom是CSS Material UI中的一个类
            </Typography>
        </Box>
    );
}

在这里插入图片描述

body1和body2
在这里插入图片描述

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值