Steven Kim
Steven Kim

Reputation: 111

React Material-UI Autocomplete customize 10 viewable suggestions max

I'm trying to use React Material UI in my project to give search suggestions, but there's nowhere in the documentation helping present only a set number of suggestions. It is currently set to displaying all fitting suggestions, so the first letter the user types in my searchbar lags a lot because it tries to suggest thousands of possible matches. Anyone know how to make it automatically give just the first few?

Upvotes: 0

Views: 308

Answers (1)

Todd Skelton
Todd Skelton

Reputation: 7239

Use a customer filter

https://material-ui.com/components/autocomplete/#custom-filter

const filterOptions = createFilterOptions({
  limit: 10
});

<Autocomplete filterOptions={filterOptions} />

Upvotes: 1

Related Questions