繁体   English   中英

有没有办法在 MUI 中创建“真正的”自定义组件?

[英]Is there a way to create 'truly' custom component in MUI?

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

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

谢谢您的回答!

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

您可以使用ButtonUnstyleduseButton钩子。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM