材质 UI - 主题样式 - 版式不起作用

Max*_*den 6 javascript reactjs material-ui

我正在尝试使用 Material UI 将版式更改应用于主题。但对象更改不起作用。然而,调色板正在工作。

我尝试对 H3 变体以及默认字体大小进行一些更改,但所有更改均不起作用。

然而,调色板上的颜色有效。

应用程序.js

import React from "react";
import "./App.css";
import Header from "./components/ui/Header";
import { ThemeProvider } from "@material-ui/styles";
import theme from "./components/ui/Theme";

function App() {
    return (
        <ThemeProvider theme={theme}>
            <Header />
        </ThemeProvider>
    );
}

export default App;
Run Code Online (Sandbox Code Playgroud)

标头/index.jsx

import React from "react";
import AppBar from "@mui/material/AppBar";
import Toolbar from "@mui/material/Toolbar";
import useScrollTrigger from "@mui/material/useScrollTrigger";
import Typography from "@mui/material/Typography";

function ElevationScroll(props) {
    const { children, window } = props;
    const trigger = useScrollTrigger({
        disableHysteresis: true,
        threshold: 0,
        target: window ? window() : undefined,
    });

    return React.cloneElement(children, {
        elevation: trigger ? 10 : 0,
    });
}

function Header() {
    return (
        <ElevationScroll>
            <AppBar color="primary">
                <Toolbar>
                    <Typography variant="h3" component="h3">
                        Nome de teste
                    </Typography>
                    <h3>Teste</h3>
                    Teste
                </Toolbar>
            </AppBar>
        </ElevationScroll>
    );
}

export default Header;

Run Code Online (Sandbox Code Playgroud)

主题.js

import { createTheme } from "@material-ui/core/styles";

const arcBlue = "#0B72B9";
const arcOrange = "#FFBA60";

export default createTheme({
    typography: {
        fontSize: 60,
        h3: {
            fontWeight: 500,
        },
    },
    palette: {
        common: {
            blue: `${arcBlue}`,
            orange: `${arcOrange}`,
        },
        primary: {
            main: `${arcBlue}`,
        },
        secondary: {
            main: `${arcOrange}`,
        },
    },
});
Run Code Online (Sandbox Code Playgroud)

如果有人可以提供帮助,我将非常感激。

Max*_*den 9

解决方案

我是从以下进口的:

import { ThemeProvider } from "@material-ui/styles";
Run Code Online (Sandbox Code Playgroud)

但是,根据文档,它需要是:

import { ThemeProvider } from "@mui/material/styles";
Run Code Online (Sandbox Code Playgroud)