简体   繁体   中英

How can you adjust the gap space in the TextBox MUI component with custom sized labels?

在此处输入图像描述

I am using material ui's (MUI) TextField component and I've increased the font size of the label. As you can see the gap in the border that exists for the label hasn't increased in size to match the now larger label.

I can't find anything in their documents regarding this so I could use some help figuring out how to fix this.

Here's the current CSS ruleset I'm using

const CssTextField = styled(TextField)({
  "& .MuiOutlinedInput-root": {
    "& fieldset": {
      borderColor: "white",
    },
    "&:hover fieldset": {
      borderColor: "white",
    },
    "&.Mui-focused fieldset": {
      borderColor: "#1976D2",
    },
  },
  input: {
    color: "white",
    fontSize: "16px",
  },
  label: {
    color: "white",
    fontSize: "16px",
  },
});

You can add this below style to your css file. This make background for your label that can overlab border

.MuiInputLabel-outlined.MuiInputLabel-shrink {
  background-color: #FFF !important;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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