14

Material UI 如何引入自定义主题

 2 years ago
source link: https://www.ixiqin.com/2021/10/material-ui-how-to-introduce-a-custom-theme/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Material UI 如何引入自定义主题

在 Next.js 中,如果你希望为 Material UI 引入自定义主题,可以如下实现

1. 设计自定义主题

参考 Theming 主题 – MUI 来定制自己的主题,所有的属性可以在 默认主题 – MUI 找到。修改你需要修改的对应项目即可。剩下的可以使用默认。

2. 修改代码,引入主题

修改你的 pages/_app.js,在其中添加如下代码,来应用你的主题。

import { ThemeProvider, createTheme } from '@material-ui/core/styles';

const themeOptions = createTheme({
  palette: {
    type: 'dark',
    primary: {
      main: '#ff9900',
    }
  },
});

function MyApp({ Component, pageProps }) {
  return (
      <ThemeProvider theme={themeOptions}> <Component {...pageProps} /></ThemeProvider>

  )
}
发布日期:2021年10月30日
d9b147a3b7e8d89bf4a5ddd0518bca30?s=85&d=monsterid&r=g

作者:Bestony

Generalist, contact me at [email protected]

查看Bestony的所有文章。

发表评论 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

评论

显示名称 *

电子邮箱地址 *

网站地址


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK