I am creating a set of reusable components (wrapped material-ui) which are being styled using CSS. I need to set the width of the component dynamically via a prop passed into the custom button.
I want to use classnames to merge the const root style defined for MyButton (I have stripped this back in the sandbox, but it sets colours, icons etc) and the dynamic sizeStyle which can be defined based on the prop passed in.
const sizeStyle: JSON = { minWidth: "300px !important"};
//always apply the buttonstyle, only apply the size style if a width prop has been supplied
const rootStyle: Object = classNames({
buttonStyle: true,
sizeStyle: props.width
///});
I can't see why the style isn't being applied to the first button on the page where there is a prop passed through - I can see on the console that the two style are supposed to be applied.
Sandbox here: https://codesandbox.io/s/css-styling-custom-muibutton-width-as-prop-36w4r
TIA