The fontSize
of each option in the dropdown is from theme.typography.body1.fontSize
. If you want to change that variant globally, do that in createTheme
:
const theme = createTheme({
typography: {
body1: {
fontSize: 22,
}
}
})
This changes the font size in both TextField
and MenuItem
:
<ThemeProvider theme={theme}>
<Autocomplete {...} />
</ThemeProvider>
You can also change the MuiAutocomplete
styles separately in createTheme
:
const theme = createTheme({
components: {
MuiAutocomplete: {
styleOverrides: {
root: {
'& label': {
fontSize: 22,
},
},
input: {
fontSize: 22,
},
listbox: {
fontSize: 22,
},
},
},
},
});
Or if you want to change the font size in an isolated component in v5, you can use sx
or styled
:
sx
<Autocomplete
options={top100Films}
ListboxProps={{
sx: { fontSize: 22 },
}}
sx={{
'& .MuiAutocomplete-input, & .MuiInputLabel-root': {
fontSize: 22,
},
}}
renderInput={(params) => <TextField {...params} label="Movie" />}
/>
styled()
const StyledAutocomplete = styled(Autocomplete)({
'& .MuiAutocomplete-input, & .MuiInputLabel-root': {
fontSize: 22,
},
});
const Option = styled('li')({
fontSize: 22,
});
<StyledAutocomplete
options={top100Films}
renderOption={(props2, option) => (
<Option {...props2}>{option.label}</Option>
)}
renderInput={(params) => <TextField {...params} label="Movie" />}
/>
