I've been attempting to replace the default MUI 5 Button styles with my custom styles using either withStyles
or a className
(created using makeStyles
), but I'm running into an issue where the default styles take precedence over my custom ones. I managed to address this problem with withStyles
by including those styles in the global style overrides when defining the theme, but the className-based approach is proving problematic.
Does anyone know how to resolve this? Below are some screenshots illustrating the strange behavior.
Edit: Here's the code used to define the custom styles:
import { Theme } from '@mui/material';
import { makeStyles } from '@mui/styles';
const BTN_WIDTH = 160;
const BTN_MIN_HEIGHT = 34;
export default makeStyles((theme: Theme) => ({
btn: {
width: BTN_WIDTH,
minHeight: BTN_MIN_HEIGHT,
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
}
}));
https://i.sstatic.net/A1943S8J.png
^ A screenshot revealing the button styles in question. (Some default styles were excluded for brevity). The screenshot demonstrates how the default styles are overriding the paddings specified by the custom styles.