下面是日期选择器组件
import React, { Fragment, useState } from "react";
import {
KeyboardDatePicker,
MuiPickersUtilsProvider
} from "@material-ui/pickers";
import DateFnsUtils from "@date-io/date-fns";
import makeStyles from "@material-ui/styles/makeStyles";
const useStyles = makeStyles({
root: {
"& .MuiInputBase-root": {
padding: 0,
"& .MuiButtonBase-root": {
padding: 0,
paddingLeft: 10
},
"& .MuiInputBase-input": {
padding: 15,
paddingLeft: 0
}
}
}
});
function InlineDatePickerDemo(props) {
const [selectedDate, handleDateChange] = useState(new Date());
const classes = useStyles();
return (
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<KeyboardDatePicker
className={classes.root}
autoOk
variant="inline"
inputVariant="outlined"
label="With keyboard"
format="MM/dd/yyyy"
value={selectedDate}
InputAdornmentProps={{ position: "start" }}
onChange={(date) => handleDateChange(date)}
/>
</MuiPickersUtilsProvider>
);
}
export default InlineDatePickerDemo;
从codeSandbox Link中,有人能告诉我如何从各个方面删除边框吗?尽管我设法知道了。MuiInput-underline:before style类负责边框宽度,但不知道将该类放在makeStyles中的何处。
5条答案
按热度按时间bn31dyow1#
您只需要稍微编辑一下
KeyboardDatePicker
元素:1.删除
inputVariant="outlined"
1.加
CodeSandbox
wvt8vs2t2#
在MUI中,您可以将variant=“standard”添加到文本字段中:
完全:
ygya80vv3#
只需要移除
inputVariant="outlined"
props,那么代码就变成了:Here您的代码修改。
imzjd6km4#
efzxgjgh5#
对于MUI Datepicker版本6及以上,我们需要使用
slotProps
。添加以下示例代码: