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

378
Vistas
MUI DatePicker default textfield cannot be customized with different font color and size

I am having an issue while using MUI DatePicker . I am not being able to customize the font color & font size of the date. My code is :

const DateSettings = () => {
  const [value, setValue] = React.useState<Date | null>();

  const handleChange = (newValue: Date | null) => {
    setValue(newValue);
  };
  return (
    <Box>
      <LocalizationProvider dateAdapter={DateAdapter}>
        <Stack spacing={3}>
            <MobileDatePicker
              label="Date mobile"
              inputFormat="MM/dd/yyyy"
              value={value}
              onChange={handleChange}
              components={{ OpenPickerIcon: CalendarIcon }}
              renderInput={(params) => (
                <TextField  {...params} />
              )}
            />
        </Stack>
      </LocalizationProvider>
    </Box>
  );
};

export default DateSettings;

I have tried adding style to the textfield using sx prop as usual. It changes the background color but doesn't change the font color & font size if I use this code block:

renderInput={(params) => (
                <TextField sx={{backgroundColor:'red',color:'white'}} {...params} />
              )}

settings image

I have also tried custom style like this, but still the same!

const useStyles = makeStyles({
  root: {
    background: "red",
    border: 0,
    borderRadius: 3,   
    color: "white",
  },
});

const DateSettings = () => {
  const classes = useStyles();
 
  return (
    <Box>
      <LocalizationProvider dateAdapter={DateAdapter}>
        <Stack spacing={3}>
            <MobileDatePicker
              className={classes.root}
              inputFormat="MM/dd/yyyy"
              value={value}
              onChange={handleChange}
              components={{ OpenPickerIcon: CalendarIcon }}
              renderInput={(params) => (
                <TextField  {...params} />
              )}
            />
         </Stack>
      </LocalizationProvider>
    </Box>
  );
};

export default DateSettings;

Is there any other way to change it?

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

0

All you had to do was inspect the text, copy the applicable classname and apply classes.root directly to .

enter image description here

const useStyles = makeStyles({
  root: {
    "& .MuiOutlinedInput-input": {
      border: 0,
      borderRadius: 3,
      color: "red",
      fontSize: 24
    }
  }
});

const DateSettings() {
  const classes = useStyles();
  const [value, setValue] = useState(Date | (null > null));

  return (
    <Box>
      <LocalizationProvider dateAdapter={AdapterDateFns}>
        <Stack spacing={3}>
          <MobileDatePicker
            inputFormat="MM/dd/yyyy"
            value={value}
            onChange={handleChange}
            components={{ OpenPickerIcon: CalendarIcon }}
            renderInput={(params) => <TextField className={classes.root} {...params} />}
          />
        </Stack>
      </LocalizationProvider>
    </Box>
  );
}

enter image description here

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