Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • digitalcrankz 1 post 71 karma points
    Mar 23, 2023 @ 11:33
    digitalcrankz
    0

    What is the use of name and slot in the styled API?

    am using MUI to create my own component library. I was tempted to use the styled API to use create all components and their sub-components. But later I found out that in order to override any style of a component or a subcomponent, I would need to pass my own className as noted here. This applies to styling via sx prop as well as styled API.

    Another place where I thought the name and slot would help is in theming using createTheme, but it seems that it actually relies on the overridesResolver to do that.

    The only place where the name and slot was useful was in creating the className for the component (that too hash prefixed, so useless for CSS targeting) and the displayName in the React devtools.

Please Sign in or register to post replies

Write your reply to:

Draft