Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
MUI Autocomplete - Make all options selected by default

I've be using this example to try and get the values in the autocomplete drop down to be automatically selected by default. I'm looking to get all the values to be selected when the page is loaded. Does anyone know how to do this?

Sandbox code : https://codesandbox.io/s/s26gz?file=/demo.js:504-523

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can control the value of the Autocomplete by overriding the value/onChange props and use useState to set the initially selected options:

const [value, setValue] = React.useState(options);

return (
  <Autocomplete
    options={options}
    value={value}
    onChange={(e, v) => setValue(v)}
    {...}
  />
);

Or if you're using uncontrolled mode, simply pass a defaultValue:

<Autocomplete
  defaultValue={options}
  {...}
/>

Codesandbox Demo

about 4 years ago · Juan Pablo Isaza Report

0

You can pass a defaultValue props to Autocomplete like this

  <Autocomplete
    options={options}
    value={value}
    defaultValue={top100Films}
    ...
  />
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!