如何更改 MUI DatePicker 中的图标?
How to change the icon in MUI DatePicker?
我无法将我的图标添加到组件中。
https://codesandbox.io/s/materialuipickers-material-demo-forked-soctc
DatePicker
的 components
属性允许您覆盖内部组件,包括 OpenPickerIcon
,所以这就是您覆盖它的方式。作为参考,请参阅 DatePicker
here:
的完整 API
import AccessibleIcon from "@mui/icons-material/Accessible";
<DatePicker
components={{
OpenPickerIcon: AccessibleIcon
}}
{...}
这是可以自定义的图标组件列表:
{
LeftArrowIcon?: elementType,
OpenPickerIcon?: elementType,
RightArrowIcon?: elementType,
SwitchViewIcon?: elementType
}
我无法将我的图标添加到组件中。
https://codesandbox.io/s/materialuipickers-material-demo-forked-soctc
DatePicker
的 components
属性允许您覆盖内部组件,包括 OpenPickerIcon
,所以这就是您覆盖它的方式。作为参考,请参阅 DatePicker
here:
import AccessibleIcon from "@mui/icons-material/Accessible";
<DatePicker
components={{
OpenPickerIcon: AccessibleIcon
}}
{...}
这是可以自定义的图标组件列表:
{
LeftArrowIcon?: elementType,
OpenPickerIcon?: elementType,
RightArrowIcon?: elementType,
SwitchViewIcon?: elementType
}