P粉0221405762023-08-15 00:57:02
You can use the renderOption
attribute to render MUI Autocomplete, the code is as follows:
<Autocomplete multiple id="tags-standard" value={value} onChange={(event, value) => setValue(value)} options={top100Films} getOptionLabel={(option) => option.title} renderInput={(params) => ( <TextField {...params} variant="standard" label="Multiple values" placeholder="Favorites" /> )} renderOption={(props, option, state) => { return ( <li {...props} style={{ ...props.style, ...(state.selected ? { backgroundColor: "yellow" } : {}) }} > {option.title} </li> ); }} />
This is a Codesandbox link.