James L.
James L.

Reputation: 14515

How to create a custom drop-down using react-select (like stackoverflow)?

Instead of a simple string using label options:

var options = [
  { value: 'one', label: 'One' },
  { value: 'two', label: 'Two' }
];

I want to use a custom component with complex data to populate each option. The selected tags could still be a value, label pair though.

A perfect example:

enter image description here

Upvotes: 1

Views: 3959

Answers (1)

TimoStaudinger
TimoStaudinger

Reputation: 42460

Yes, react-select lets you pass in a custom menu component via the menuRenderer prop:

Renders a custom menu with options; accepts the following named parameters: menuRenderer({ focusedOption, focusOption, options, selectValue, valueArray })


More info in react-select's docs.

Upvotes: 2

Related Questions