【问题标题】:Is there a way to create 'truly' custom component in MUI?有没有办法在 MUI 中创建“真正的”自定义组件?
【发布时间】:2021-12-22 21:38:05
【问题描述】:

我知道我可以自定义标准的 MUI 组件,例如 Button,但我可以创建自己的 MyCustomButton,它具有 'muiName' = 'MyCustomButton' 并且可以通过主题配置进行自定义:

createTheme({
  components: { 
    MyCustomButton: {
      styleOverrides: { 
        root: {...}, 
        MyCustomButtonSubComponent: {...}
      }
    }
  }
})

感谢您的回答!

【问题讨论】:

    标签: javascript reactjs material-ui react-material


    【解决方案1】:

    您有几个选择。假设您想创建一个具有 MUI 按钮行为的完全自定义按钮。

    您可以使用ButtonUnstyleduseButton 挂钩。

    https://mui.com/components/buttons/#unstyled

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-25
      • 2010-10-23
      • 2019-08-22
      • 2011-04-10
      • 2021-09-30
      • 1970-01-01
      • 2011-10-28
      • 1970-01-01
      相关资源
      最近更新 更多