2

I want to change the font size of the drop down items.

I tried different ways of changing font size as follows,

How do I change Material UI Autocomplete font size?

How to change fontsize of options in Material ui autocomplete?

But those ways are not working for me, hope it is due to they are for version 4.

Here is my Autocomplete component.

<Autocomplete
   size="small"
   disablePortal
   options={getVisaOptions()}
   renderInput={(params) => <TextField  {...params} label="Select VISA"/>}
/>
shayanmalinda
  • 1,925
  • 3
  • 12
  • 23

2 Answers2

3

it worked with customizing renderOption

<Autocomplete
    size="small"
    disablePortal
    options={getVisaOptions()}
    getOptionLabel={(option) => option.label}
    renderOption={(props, option) => (
        <Box style={{fontSize: 14}} {...props}>
            {option.label}
        </Box>
    )}
    renderInput={(params) => <TextField  {...params} label="Select VISA"/>}
/>
shayanmalinda
  • 1,925
  • 3
  • 12
  • 23
  • Thank you! I got here from your prior post at https://stackoverflow.com/questions/64963549/how-to-change-fontsize-of-options-in-material-ui-autocomplete when I was having the exact same issue. – Dave Dec 20 '22 at 22:06
0

About your question, you could set renderOption and set style for the option font size, here is my example you can try.

<Autocomplete
   size="small"
   disablePortal
   options={getVisaOptions()}
   renderInput={(params) => <TextField  {...params} label="Select VISA"/>}
   renderOption={(props, option) => (
             <Typography sx={{fontSize: 18}}>
                {option.label}
             </Typography>)
            }
/>
wildgamer
  • 297
  • 1
  • 3