I need to customize the material-ui autocomplete control so it's not so tall. I found a sample that works well to change the MuiOutlinedInput outline color using createMuiTheme on the Autocomplete's TextField. The codesandbox is here: Code Example
This is my theme override code and I added an override for the padding of the input class:
const theme = createMuiTheme({
overrides: {
MuiOutlinedInput: {
root: {
"& $notchedOutline": {
borderColor: "green"
},
"&:hover $notchedOutline": {
borderColor: "red"
},
"&$focused $notchedOutline": {
borderColor: "purple"
},
"& $input": {
padding: "1px"
}
}
}
}
});
And this is the component code:
<Autocomplete
id="country-select-demo"
style={{ width: 300 }}
options={countries}
getOptionLabel={option => option.label}
renderInput={params => (
<MuiThemeProvider theme={theme}>
<TextField {...params} label={"Countries"} variant="outlined" />
</MuiThemeProvider>
)}
/>
The problem is my padding for the input class gets overridden by this:
.MuiAutocomplete-inputRoot[class*="MuiOutlinedInput-root"] .MuiAutocomplete-input
Anything I can do to make my customization not get overridden by the above? I'm also open to other techniques other than createMuiTheme, or perhaps styling other parts of the autocomplete. I just need to make it not so tall.
Thanks!