autocomplete onselect event mui code example

Example 1: how to get value from autocomplete material ui

<Autocomplete
    onChange={(event, value) => console.log(value)} // prints the selected value
    .....
    renderInput={params => (
        <TextField {...params} label="Label" variant="outlined" fullWidth />
    )}
/>

Example 2: material ui autocomple how make first option is selected as default

<Autocomplete
    id="id"
    options={Options}
    getOptionLabel={option => option.label}
    defaultValue={Options.find(v => v.label[0])} 
    renderInput={params => (
      <TextField {...params} label="label" variant="outlined" />
    )}
  />

Tags:

Misc Example