react-select - how do I change the background colour of the control when option x is selected?

Viewed 140

I'm trying to change the background colour of the control depending on the value of the option that is currently selected

For example, when the value 'new' is selected, I would like to have the control background colour to be red. When it is 'in-progress', I would like the control background colour to be yellow. When it is 'signed' I would like it to be green etc. I should also mention that I have multiple rows in a table with selects in them ('in-progress etc.) and they all have different values depending on the value in each select

I've tried a number of things, but the background colour doesn't change from how it's initially set. I have seen this How to change react-select options styles when select but this issue resolves when something isSelected and it's a ternary operator. I need something that will be able to have if statements (if value === 'in-progress' for example) or case statements to assign a different background colour to the control based on the value selected in the select component

Does anyone have any suggestions?

Any help would be greatly appreciated

0 Answers
Related