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

432
Views
How to use Material-UI autocomplete component to be able to display and filter multiple words sperated by '-'(dash) for each option effectively

Problem We need Material-UI autocomplete component to be able to display and filter multiple words separated by special characters like'-'(dash) for each option effectively.

Example: option dropdown must have string similar to, Username - Phone.

We have tried https://mui.com/material-ui/react-autocomplete/#search-input, but in my codebase, the filtration action is not accurate. If we use phone number instead in the autocomplete field to filter autocomplete options; we are not getting the right result filtered.

Note: values in option field in the future will include names with special characters in them along with phone number separated by dash.

Code:

import * as React from 'react';
import TextField from '@mui/material/TextField';
import Autocomplete from '@mui/material/Autocomplete';

export default function ComboBox() {
  return (
    <Autocomplete
      disablePortal
      id="combo-box-demo"
      options={Users}
      getOptionLabel={(Users) => Users.label +' - ' + Users.phone}
      sx={{ width: 300 }}
      renderInput={(params) => <TextField {...params} label="Users" />}
    />
  );
}

// Userslists
const Users= [
  { label: 'username1', phone: 912345121},
  { label: 'username2', phone: 912345122},
  { label: 'username3', phone: 212345676},
  { label: 'username4', phone: 333223311},
  { label: 'username5', phone: 777777232},
  { label: 'username6', phone: 787873333},
];

All comments are welcome :)

about 4 years ago · Juan Pablo Isaza
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!