在MaterialCSS中使用createTheme定义自定义的H1、H2、H3样式的方法
P粉549412038
P粉549412038 2024-04-05 12:38:32
[CSS3讨论组]

我有一个使用NextJSMaterialCSS的应用程序,并创建了以下主题

import { createTheme } from '@mui/material/styles';

export const darkTheme = createTheme({
  palette: {
    mode: 'dark',
  },
  components: {
    MuiButton: {
      styleOverrides: {
        root: {
          color: 'white',
        },
      },
    },
  },
});

export const lightTheme = createTheme({
  palette: {
    mode: 'light',
  },
});

我知道如何为Mui组件覆盖样式。 如何为我的主题中的<h3>元素定义自定义样式,以便在暗主题上具有不同的h3样式而在亮主题上具有不同的h3样式?

P粉549412038
P粉549412038

全部回复(1)
P粉364129744
const theme = createTheme({
  typography: {
    h3: {
      fontSize: 30,
    },
    subtitle1: {
      fontSize: 12,
    },
    body1: {
      fontWeight: 500,
    },
    button: {
      fontStyle: 'italic',
    },
  },
});

文档:
https://mui.com/material-ui/customization/typography/#variants

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号