I apologize if this is a duplicate question, but i was not able to find the answer anywhere.
I'd like to set a conditional formatting to the control label, but not on the option labels.
For Example, I want the label on the control to be Show: All while i want the label in the options list to just be All. I also have other options such as Human Names that i want to conditionally _not_ set the label to be anything different. When the All option is selected, the control shows Show: All and when the John Doe option is selected, the control still just shows John Doe is my desired outcome
getOptionLabel changes both the labels in the options and the control
I would love something like a controlLabelFormatter or something of the sorts - I've seen these in other selector packages and was totally expecting it here - Which is why i think i might just be missing something.
Thanks!
There is already a prop which would allow for something like this: formatOptionLabel, which accepts a function as a value. It gets the option as its first argument and a context as a second.
Two contexts I found were value for formatting the option in the control and menu for an option in the dropdown menu.
Thank you so much! it's the context that i wasn't aware of - super helpful!
Most helpful comment
There is already a prop which would allow for something like this:
formatOptionLabel, which accepts a function as a value. It gets the option as its first argument and a context as a second.Two contexts I found were
valuefor formatting the option in the control andmenufor an option in the dropdown menu.