4

I want to change the placeholder fontsize of Material Ui Autocomplet. Is there any way?

enter image description here

             <Autocomplete
                  multiple
                  id="tags-outlined"
                  options={top100Films}
                  getOptionLabel={(option) => option.title}
                  defaultValue={[top100Films[13]]}
                  filterSelectedOptions
                  size="small"

                  renderInput={(params) => (
                    <TextField
                      {...params}
                     
                      variant="outlined"

                      placeholder="Enter Transshipment Ports"

                      
                    />
                  )}
                />
Daniel Logvin
  • 502
  • 7
  • 26
theWanderer
  • 576
  • 2
  • 10
  • 30

3 Answers3

12

In your example, you can target the input element of the component you render in renderInput which is TextField using makeStyles

const useStyles = makeStyles({
  customTextField: {
    "& input::placeholder": {
      fontSize: "20px"
    }
  }
})

<TextField
  classes={{ root: classes.customTextField }}
  {...params}
  variant="outlined"
  placeholder="Enter Transshipment Ports"
/>

Example below using forked MUI demo

Edit Material demo (forked)

95faf8e76605e973
  • 13,643
  • 3
  • 24
  • 51
2

The sx property allows users to override the styling applied to the MuiFormLabel-root object, including the font size. This is useful for creating custom labels that better suit the user's design needs.

<TextField
        {...props}
        sx={{
          '& .MuiFormLabel-root': {
            fontSize: '0.8rem',
          },
        }}
      />
Guit Adharsh
  • 189
  • 1
  • 10
0

You can just add the ::placeholder css to the class/id of the input field, and change the font-size

Example:

#tags-outlined::placeholder {
   font-size: 14px;
}
Lafa
  • 513
  • 2
  • 20