Andrew Chmil
Andrew Chmil

Reputation: 19

Is there a way to group options in Input in react-select?

I am using react-select.

I need to group options in the input. The next values should be added to a specific group just like it is in "MenuList" component with groups

here what I need

https://prnt.sc/qybffp

Ideas on how to do this?

For now, I have only one idea to deal with the Multivalue component (each group is a separate Multivalue component). But not sure it's a good idea)

Upvotes: 1

Views: 4153

Answers (1)

louie kim
louie kim

Reputation: 509

im not sure if you want to achieve something like this.

const selected_options = [{
    label: "Dark Colours",
    options: [{
        label: "colour 1",
        value: "value1"
      },
      {
        label: "colour 2",
        value: "value2"
      }
    ]
  },
  {
    label: "Light Colours",
    options: [{
        label: "colour 3",
        value: "value3"
      },
      {
        label: "colour 4",
        value: "value4"
      }
    ]
  },
];

Upvotes: 1

Related Questions