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

136
Vistas
How do I change the style of a prop in <TextField>?

I'm rendering <TextField> twice using my defined DatePicker.js component. So, whenever the user clicks on the <CalendarIcon> which is inside the <TextField>, small calendar will open up. I want to style the label in the <TextField> in a specific way. Currently, this is how it looks.

enter image description here
You can see that 'To' label of the second <TextField> is visible. It should come behind the calendar and should not show up.

class DatePickerInput extends React.Component {
  render() {
    const {
      classes,
      label,
      selectedDate
    } = this.props;
    return (<TextField
        fullWidth
        variant="filled"
        label={label}
        onClick={this.props.onClick}
        value={selectedDate.format("MM-DD-YYYY")}
        InputLabelProps={{
          shrink: true
        }}
        InputProps={{
          className: classes.input,
          endAdornment: (<CalendarIcon color="primary" />)
        }}
      />)
  }
}
class DatePicker extends React.Component {

  render() {
    const {
      label,
      value,
      minDate,
      maxDate,
      onChange
    } = this.props;


    return (
      <ReactDatePicker
        selected={value.toDate()}
        minDate={minDate.toDate()}
        maxDate={maxDate.toDate()}
        customInput={<DatePickerInputComp
          selectedDate={value}
          label={label}
        />}
        onChange={onChange} />
    )
  }
}

The problem:
How do I make the 'To' label not show up when the <CalendarIcon> pops up. I want to style the prop 'label' of TextField but I'm not sure of how I can do it.

The Updated Code:

const inputStyles = theme => ({
  icon: {
     zIndex: 1029,
   },
});
class DatePicker extends React.Component {

  render() {
    const {
      label,
      value,
      minDate,
      maxDate,
      onChange,
    } = this.props;
    const { classes } = this.props;


    return (
      <ReactDatePicker
        selected={value.toDate()}
        minDate={minDate.toDate()}
        maxDate={maxDate.toDate()}
        customInput={<DatePickerInputComp
          selectedDate={value}
          label={label}
        />}
        wrapperClassName={classes.icon}
        onChange={onChange} />
    )
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can add a higher z index for the react-datepicker component in order to make it visible at the top stack.

 <ReactDatePicker
    selected={value.toDate()}
    minDate={minDate.toDate()}
    maxDate={maxDate.toDate()}
    customInput={<DatePickerInputComp
    selectedDate={value}
    label={label}
    wrapperClassName="datePicker"
  />

I've added a wrapperClassname datePicker in order to make the styling easier.

.datePicker{
 z-index: 999
}

Temporarily gave the z-index as 999, You can alter it to a lower value after defining a z-index for the text field.

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