gpt4 book ai didi

reactjs - 如何更改 Material ui中的默认颜色

转载 作者:行者123 更新时间:2023-12-01 21:46:10 25 4
gpt4 key购买 nike

希望更改我的应用程序的主要颜色和次要颜色。手册说这就是你所需要的,但我仍然在我的应用程序中看到基本的蓝色/红色默认颜色。我一直在离开这个引用 https://material-ui.com/customization/color/

import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import { createMuiTheme } from "@material-ui/core";
import { MuiThemeProvider } from "material-ui/styles";

const theme = createMuiTheme({
palette: {
primary: {
main: "#ff8f00"
},
secondary: {
main: "#ffcc80"
}
}
});

ReactDOM.render(
<MuiThemeProvider theme={theme}>
<App />
</MuiThemeProvider>,
document.getElementById("root")
);

最佳答案

您可以简单地使用 @material-ui/core 中的 ThemeProvider 而不是 @material-ui/styles 中的 MuiThemeProvider

import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import { createMuiTheme, ThemeProvider } from "@material-ui/core";

const theme = createMuiTheme({
palette: {
primary: {
main: "#ff8f00"
},
secondary: {
main: "#ffcc80"
}
}
});

ReactDOM.render(
<ThemeProvider theme={theme}>
<App />
</ThemeProvider>,
document.getElementById("root")
);

关于reactjs - 如何更改 Material ui中的默认颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60417298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com