0

我尝试对 MUI AppBar 进行主题化,但我对主题化一无所知。我可以在不使用样式组件或其他样式 api 的情况下为 AppBar 设置主题样式吗?

调色板.js

import { createTheme } from '@mui/material/styles';
const theme = createTheme({
    palette: {
        primary: {
            main: "#000F04"
        }
    }
});

应用程序.js

import theme from "../../styles/palette";
import { ThemeProvider } from '@mui/material/styles';

const App = () => {
  return (
    <ThemeProvider theme={theme}>
      <AppBar position="static" color="primary">
        <Toolbar>
        </Toolbar>
      </AppBar>
    </ThemeProvider>
  )
}

4

1 回答 1

0

你的密码箱工作。

sx如果您需要添加特定样式, 请使用道具。https://mui.com/system/the-sx-prop/

您也可以覆盖主题的样式:https ://mui.com/customization/theme-components/#heading-global-style-overrides

于 2021-09-27T15:05:56.903 回答