Shubhi Khandelwal
Shubhi Khandelwal

Reputation: 1

react-select-show label + value when a label is selected from dropdown

I have a use case in my UI where for react-select component I want to show label in the dropdown but when we select the label, the selected option shown should be label + value. How can I implement this?

Upvotes: 0

Views: 3556

Answers (1)

Steve -Cutter- Blades
Steve -Cutter- Blades

Reputation: 5432

Use the formatOptionLabel prop to create your layout for your 'selected' option (the display in the search field), but use a custom Option layout for the display of your 'option's (or, conversely, use the prop to create your 'option' layout and provide a custom SingleValue or MultiValueLabel component for the display in the search field).

The documentation tells you how to apply custom components.

Upvotes: 1

Related Questions