简体   繁体   English

禁用浮动左上标签动画素材-ui密码输入ReactJS

[英]Disable floating top left label animation material-ui password input ReactJS

i found an exisitng input with a hide/show password icon, but the probleme is that floating label since iam using material ui and i didn't find a way to remove that animation and make it look like a simple input text with a placeholder我找到了一个带有隐藏/显示密码图标的现有输入,但问题是浮动标签,因为我正在使用材质 ui,我没有找到删除该动画并使其看起来像带有占位符的简单输入文本的方法

this is my code :这是我的代码:

   <Box sx={{ display: "flex", flexWrap: "wrap" }}>
  <div>
    <FormControl sx={{ m: 1, width: "25ch" }} variant="outlined">
         <InputLabel >
        Type here...
      </InputLabel>
      <OutlinedInput
        id="outlined-adornment-password"
        type={values.showPassword ? "text" : "password"}
        value={values.password}
        onChange={handleChange("password")}
        endAdornment={
          <InputAdornment position="end">
            <IconButton
              aria-label="toggle password visibility"
              onClick={handleClickShowPassword}
              onMouseDown={handleMouseDownPassword}
              edge="end"
            >
              {values.showPassword ? <VisibilityOff /> : <Visibility />}
            </IconButton>
          </InputAdornment>
        }
        label="Password"
      />
    </FormControl>
  </div>
</Box>

it looks like this when i click on the input so i wanna remove that floating effect and make it looks normal当我点击输入时它看起来像这样所以我想删除那个浮动效果并让它看起来很正常

在此处输入图像描述

when using shrink={true}使用收缩={true} 时

在此处输入图像描述

You need to add shrink={true} to InputLabel to remove the label floating effect.您需要在InputLabel中添加shrink={true}以消除标签浮动效果。

      <InputLabel shrink={true}>
        Type here...
      </InputLabel>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM