Material-ui/pickers: 隐藏标签

Material-ui/pickers: Hide the label

默认情况下,如果未选择任何内容,标签将作为占位符放置(如下面的屏幕截图所示)。

<KeyboardDatePicker InputAdornmentProps={{
          position: 'start'
        }}
/>

有没有办法缩小标签并保持占位符为空?我尝试添加 InputAdornmentProps={{position: 'start'}} 并且它有所帮助(在下面的屏幕截图中)除了我不需要图标在开始时,我需要它保持原样,在右边。 有没有办法实现它?我正在使用来自 https://material-ui-pickers.dev/api/KeyboardDatePicker

的 KeyboardDatePicker

Any prop not recognized by the pickers and their sub-components are passed down to material-ui TextField component.

所以你需要做的只是从 TextField 组件中添加所需的道具来缩小标签。结果将如下所示:

<KeyboardDatePicker InputLabelProps={{ shrink: true }} />