首页 > 解决方案 > How to set TextField to empty string?

问题描述

I want the text field to contain the data, and if column is null, the textField will be empty as well. This solution works, but it seems ugly as it contains a string. If I use an empty string '' then the label "becomes" the value ( instead of appearing as the label of the textfield, it appears as the value it self, position wise).. What do I need to change ?

  <TextField
          margin="normal"
          fullWidth
          inputProps={{
            disabled: true
          }}
          // eslint-disable-next-line
          label={labels.accountNumber}
          value={props.column || ' '}
    />

标签: reactjsmaterial-ui

解决方案


请添加它将保留上侧的标签。

InputLabelProps={{
      shrink: true,
    }}

推荐阅读