小编Gre*_*use的帖子

在 Material-ui Autocomplete 组件上设置文本颜色、轮廓和内边距

我们想更改 Material-ui 自动完成组件上的文本颜色、轮廓和填充。

代码如下所示:

              <FormControlLabel
                label="Please enter desired service:"
                labelPlacement="start"
                control={
                  <Autocomplete
                    id="services"
                    options={props.serviceTypes}
                    getOptionLabel={option => option.name}
                    className={classes.inputRoot}
                    style={{ width: 400, paddingLeft: 20 }}
                    renderInput={params => (
                      <TextField
                        {...params}
                        label=""
                        className={classes.inputRoot}
                        variant="outlined"
                        fullWidth
                      />
                    )}
                    onChange={setService}
                  />
                }
              />
Run Code Online (Sandbox Code Playgroud)

我们可以通过这样的代码更改 TextInput 颜色

                        InputProps={{
                          className: classes.inputColor
                        }}
Run Code Online (Sandbox Code Playgroud)

但是以这种方式应用样式会影响 AutoComplete 功能(它失去了自动完成功能并且表现得像一个普通的 TextField)。

我们尝试了许多 style 和 className 选项都无济于事。

感谢任何建议。

reactjs material-ui

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

material-ui ×1

reactjs ×1