悬停样式覆盖时的 Material-ui v5 参考调色板颜色

时间:2021-07-13 01:35:54

标签: material-ui

使用以下主题(使用 styleOverrides)和用法,我如何更改引用调色板和颜色变体的悬停样式?

<Button color="secondary">
  I expect this button's hover color to be red, and the variant to be contained
</Button>
const theme: Theme = createTheme({
  palette: {
    mode: "light",
    primary: {
      main: "green"
    },
    secondary: {
      main: "red"
    }
  },
  components: {
    MuiButton: {
      defaultProps: {
        variant: "contained"
      },
      styleOverrides: {
        root: {
          "&:hover": {
            backgroundColor: palette.main
          }
        }
      }
    }
  }
})

0 个答案:

没有答案