[英]How to override the TextInput from React-Admin
I only want to override the specific fields.我只想覆盖特定字段。 Setting the custom theme will override the other fields too.
设置自定义主题也将覆盖其他字段。
Tried using useStyles but didn't work and tried using direct style props but that also didn't work.尝试使用 useStyles 但没有用并尝试使用直接样式道具但也没有用。
const useStyles = makeStyles({
MuiInputBase: {
root: {
width: "800px"
}
}
});
<TextInput className={classes.MuiInputBase} variant="outlined" label="Search" source="search" alwaysOn />
As explained in the docs, className
only allows to override the style of the root component.如文档中所述,
className
仅允许覆盖根组件的样式。 To override the inner styles, you must use the classes
prop:要覆盖内部 styles,您必须使用
classes
属性:
const useStyles = makeStyles({
MuiInputBase: {
root: {
width: "800px"
}
}
});
const MyInput = () => {
const classes = useStyles();
return <TextInput classes={classes} variant="outlined" label="Search" source="search" alwaysOn />;
};
More details at https://marmelab.com/react-admin/Theming.html#overriding-a-component-style更多细节在https://marmelab.com/react-admin/Theming.html#overriding-a-component-style
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.