In the process of developing a collection of reusable components, I have utilized material-ui and styled them with CSS. One specific requirement is to dynamically set the width of a component through a prop passed into a custom button.
My goal is to leverage classnames in order to combine the const root style defined for MyButton (for features like colors and icons) with a dynamic sizeStyle that can adjust based on the prop provided.
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
});
Despite my efforts, it seems that the style is not being applied to the first button on the page when a prop is passed through - even though the console indicates that both styles should be present.
View the sandbox here: https://codesandbox.io/s/css-styling-custom-muibutton-width-as-prop-36w4r
Thanks in advance!