I'm working on converting an existing codebase to Material UI and am trying to set a standard going forward for how the components are styled.
I've previously worked in a codebase where all the components are styled using the sx
prop and didn't notice any particular issues. However, I've seen it recommended in various places that the sx
prop should only be used for 'one time' styling and that the styled()
API would be a better choice if you need multiple components of the same type to have the same styling.
Although what I don't understand is why that is? If I created a component that was a wrapper around an inner Material UI component and the inner component had been styled with the sx
prop. Wouldn't this also achieve the goal of having multiple components of the same type having the same styling? If so, what use is there for the 'styled()' API?