I want to add an icon to the beginning of the Autocomplete component. (with startAdornment)
I read that Autocomplete is a normal text input
So far I tried adding
InputProps={{startAdornment: <InputAdornment position="start">kg</InputAdornment>,}}
to the <TextField /> component. Like below:
<Autocomplete
{...defaultProps}
onChange={(event, value) => {
handleOnChange(event, value);
}}
id="disable-close-on-select"
sx={{ width: 300 }}
renderInput={params => (
<TextField
InputProps={{
startAdornment: <InputAdornment position="start">kg</InputAdornment>,
}}
{...params}
label="search"
variant="standard"
/>
)}
/>
Any help would be great, as I'm a beginner to the Material-UI ecosystem.
defaultProps is defined like this.
const defaultProps = {
options: data,
getOptionLabel: (option: DataType) => option?.id,
};