【问题标题】:Material Ui datepicker - Styling the calendar icon in the text fieldMaterial Ui datepicker - 在文本字段中设置日历图标的样式
【发布时间】:2020-06-22 05:03:54
【问题描述】:

我正在尝试在 React 的 Material UI 的键盘日期选择器文本字段中设置日历图标的样式(特别是增加图标的字体大小)。

<KeyboardDatePicker
  keyboard={!this.props.isDisabled}
  keyboardIconProps={{ fontSize: "35px" }}
  clearable
  disabled={this.props.isDisabled}
  error={this.state.isError}
  helperText={this.state.errorMsg}
  pickerRef={node => (this.picker = node)}
  InputProps={{ disableUnderline: true, disabled: this.props.isDisabled }}
  onError={console.log}
  value={this.props.storeValue}
  onChange={this.onChangeCallback}
  format={this.props.displayFormat}
  onBlur={this.onBlurCallback}
  disableOpenOnEnter
  InputLabelProps={this.inputLabelProps}
  disableFuture={this.props.disableFuture}
  disablePast={this.props.disablePast}
/>

我尝试设置 KeyboardButtonProps 但它似乎没有设置图标的样式。我在网上搜索并没有解决我的问题。任何帮助将非常感激。干杯!

【问题讨论】:

  • 您能否提供一个在线示例,至少是您正在使用的 material-ui 组件的链接

标签: material-ui


【解决方案1】:

假设您使用来自@material-ui/pickersKeyBoardDatePicker

您可以通过 keyboardIcon 属性更改图标,该属性需要一个 ReactNode 作为子节点。

基本上只需将以下prop 添加到您的组件中

keyboardIcon={<SomeReactElement/>}

Here你有一个工作沙箱

【讨论】:

  • 我昨天做了同样的解决方案,它对我有用。无论如何感谢您花时间提供答案:)
猜你喜欢
  • 2018-04-08
  • 2021-12-18
  • 2021-09-25
  • 1970-01-01
  • 2018-07-15
  • 2023-01-13
  • 1970-01-01
  • 2019-05-13
  • 2021-08-03
相关资源
最近更新 更多