CSS approach is right. this style should be applied to the input
element and to apply the styles to the input element, target the input
class instead of root
. And another issue is here you're trying to use makeStyles
and createMuiTheme
at once which is not right.
To style using createMuiTheme
this is the way:
const theme = createMuiTheme({
overrides: {
MuiInput: {
input: {
"&::-webkit-outer-spin-button, &::-webkit-inner-spin-button": {
"-webkit-appearance": "none",
display: "none"
}
}
}
}
});
And then wrap your app within <MuiThemeProvider>
.
To do this using makeStyles
:
const useStyles = makeStyles((theme) => ({
inputStyle: {
"&::-webkit-outer-spin-button, &::-webkit-inner-spin-button": {
"-webkit-appearance": "none",
display: "none"
}
}
}));
And then target the input
class by using InputProps
prop.
export default function TextStyle() {
const classes = useStyles();
return (
<div>
<TextField
InputProps={{ classes: { input: classes.inputStyle } }}
type="number"
/>
</div>
);
}
Here is the working demo:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…