代码之家  ›  专栏  ›  技术社区  ›  carloscc

更改颜色输入标签材料界面

  •  0
  • carloscc  · 技术社区  · 8 年前

    <InputLabel>NAME</InputLabel>
    

    我的问题是,文本是白色的(我不明白为什么是白色的,也许我做错了什么),我看不到白色的白色。我怎么把颜色改成黑色?

    5 回复  |  直到 8 年前
        1
  •  4
  •   siddrajpoot    8 年前

    你可以给我 <InputLabel />

    <InputLabel classname="test-label">This is a label</InputLabel>
    

    .test-label: {
        color: #000000 !important;
    }
    

    < 通过 <TextField /> 成分

    <输入标签/> <文本字段/> 输入标签属性:

    <TextField
       label="This is a label"
       InputLabelProps={{
         className: "test-label" 
       }}
    />
    

    在样式表中:

    .测试标签:{
    }
    
        2
  •  2
  •   RedPandaz    7 年前

    这对我有用

    <TextField
       label="This is a label"
       InputLabelProps={{
         className: classes.formLabel 
       }}
    />
    
      formLabel: {
        color: '#000,
        '&.Mui-focused': {
          color: '#000
        }
      }
        3
  •  2
  •   noName94    6 年前

    使用 withStyles classes overriding with classes 部分和 implementation of the component 更多细节。

    阅读的API InputLabel here

    const styles = theme => ({
     
      cssLabel: {
        color:'blue',//required color
        
      },
      
      )}

    使用应用样式 FormLabelClasses 财产。

    <InputLabel
              FormLabelClasses={{
                root: classes.cssLabel,
                focused: classes.cssFocused,
              }}
              htmlFor="custom-css-input"
            >
              Custom CSS
            </InputLabel>

    风格

    参考 Customised input

        4
  •  0
  •   Homura Lin    8 年前

    反应.js?

    试用

    const divStyle = {
      color: 'blue',
    };
    <InputLabel style={divStyle} >NAME</InputLabel>
    
        5
  •  0
  •   gotnull mzelina    8 年前

    你可以给我 style 以下标签如下:;

     <InputLabel style="color:black;">NAME</InputLabel>
    

    或

    InputLabel

    InputLabel{  
      color: black;
    }
    
        6
  •  0
  •   OlliT    7 年前

    当输入标签处于焦点时,它的颜色不一定保持不变,并且将被默认值覆盖。我解决这个问题并使字体颜色保持不变的方法是在typescript中执行以下操作:

    const styles = (theme: Theme) => createStyles({
        formText: {
            color: theme.palette.secondary.contrastText, 
            '&$formLabelFocused': {color: theme.palette.secondary.contrastText}
        },
        formLabelFocused: {
        }
    })
    
    class Example extends React.Component<>{
        public render() {
               <FormControl>
                        <InputLabel 
                            FormLabelClasses={{                        
                                root: classes.formText,
                                focused: classes.formLabelFocused
                            }}
                        >
                            Currency
                        </InputLabel>
              </FormControl>
              <Select>
                        <MenuItem key={1}>Example</MenuItem>
              </Select>
        }
    }
    

    在得到正确的解决方法之前,我在这方面做了很多努力

        7
  •  0
  •   4b0 Agit    7 年前

    请试试这个:

    const divStyle = {
      color: 'blue',
    };
    <InputLabel style={divStyle} >NAME</InputLabel>
    
        8
  •  0
  •   Dharman vijay    5 年前

    <Box>
              <TextField
                onChange={handleChange("quantity")}
                label="$ Quantity"
                variant="filled"
                InputLabelProps={{
                  style: { color: "cadetblue" }
                }}
              />
            </Box>
    

    enter image description here