简体   繁体   中英

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

I know that I can customize standard MUI components like Button, but can I create my own MyCustomButton, that will have 'muiName' = 'MyCustomButton' and that could be customized via theme configurations:

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

Thank you for your answers!

You have a few options. Let say you want to create a fully customized button with MUI button's behavior.

You can use ButtonUnstyled or the useButton hook.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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