Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

309
Vistas
Extra space in the label when shrink is true with font size 12px in textfield mui

I'm trying to customize the textField component but I have an issue with the label when it's shrinked:

import * as React from "react";
import TextField from "@mui/material/TextField";
import { createTheme } from "@mui/material/styles";
import createStyled from "@mui/system/createStyled";
import type { TextFieldProps } from "@mui/material/TextField";

const defaultTheme = createTheme({});
const styled = createStyled({ defaultTheme });

const CustomTextField = styled(TextField)<TextFieldProps>(
  ({ theme, size }) => ({
    "& .MuiOutlinedInput-root": {
      height: size === "small" ? theme.spacing(5) : theme.spacing(6)
    },
    "& .MuiInputLabel-root": {
      transform: "translate(14px, 8px) scale(1)"
    },
   "& .MuiInputLabel-shrink": {
      transform: "translate(12px, -9px) scale(0.75)",
      fontSize: "12px",
      fontWeight: 500,
      letterSpacing: 0.6,
      lineHeight: '20px',
      "&.MuiInputLabel-sizeSmall": {
        transform: "translate(12px, -9px) scale(0.75)"
      }
    }
  })
);

export default function BasicTextFields() {
  return (
    <CustomTextField
      id="outlined-basic"
      label="long"
      variant="outlined"
      size="medium"
      InputLabelProps={{ shrink: true }}
    />
  );
}

There is extra space between the border and the text: Long Label

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

here is a show case for Mui filedSet and legend in TextFiled component.

import * as React from "react";
import TextField from "@mui/material/TextField";
import { createTheme } from "@mui/material/styles";
import createStyled from "@mui/system/createStyled";
import type { TextFieldProps } from "@mui/material/TextField";

const defaultTheme = createTheme({});
const styled = createStyled({ defaultTheme });

const CustomTextField = styled(TextField)<TextFieldProps>(
  ({ theme, size }) => ({
    "& .MuiOutlinedInput-root": {
      height: size === "small" ? theme.spacing(5) : theme.spacing(6),
      '& fieldset legend span':{
        opacity:1,
        backgroundColor:'blue',
        marginRight:10,
      }
    },
    "& .MuiInputLabel-root": {
      transform: "translate(14px, 8px) scale(1)",
      backgroundColor:'red'
    },
    "& .MuiInputLabel-shrink": {
      transform: "translate(12px, -9px) scale(0.75)",
      "&.MuiInputLabel-sizeSmall": {
        transform: "translate(12px, -9px) scale(0.75)"
      }
    }
  })
);

export default function BasicTextFields() {
  return (
    <CustomTextField
      id="outlined-basic"
      label="long"
      variant="outlined"
      size="medium"
      InputLabelProps={{ shrink: true }}
    />
  );
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda