Add alwaysDisplayPlaceholder prop (a Floating Label theme)
Thank you for this library!
Floating Label: I'd like to create a Floating Label theme for this package (just using CSS), but it expects the placeholder to persist along with the current value.
The alwaysDisplayPlaceholder prop would be an outstanding option for what I'm expecting to see.
Here is my use case:
-
Initially, in my form, labels are everywhere.

-
Then it floats the inline label up above the input after the user focuses the select.

-
Finally, when an option is selected, the inline label disappears entirely.

Cheers!
Also see - #2143 #1126
I'd love this too, please! I don't want to have to fork this repo.
To leave an update, I just created a component wrapper which contains the label, then removed the Select built-in label and finally listened to the Select events 'onBlur', 'onChange', 'onFocus' to style the label as desired.
If needed I could share a CodePen with a better explanation, just let me know.
Yes, a CodePen would be fantastic @carlosbensant
Just to clarify, my issue is slightly different from yours - I need the placeholder specifically to stick around, not the label:

@carlosbensant or @tiffwu, I'd also greatly appreciate a CodePen with your working example(s)!
@carlosbensant a CodePen would be greatly appreciated!
@carlosbensant , that's fantastic! I would like to see the codepen as well.
@carlosbensant That would be great! Could you please share it with us?
+1
@carlosbensant Hi! Can you please share it?
+1
Please, share it! ;) +1
To leave an update, I just created a component wrapper which contains the label, then removed the Select built-in label and finally listened to the Select events 'onBlur', 'onChange', 'onFocus' to style the label as desired.
If needed I could share a CodePen with a better explanation, just let me know.
@carlosbensant Hi! Please share it ? thank you !
Here's what we do as a gist
If anyone wants to try and make this possible without a wrapper, I think it should be a part of the library. Let me know, with some help, I think we can work out a better solution.
@c-moss-talk Done. Here is the example.
All I did was using the Components Framework react-select provides to customize the ValueContainer in which Placeholder resides.
@Rall3n yup, that's perhaps the best approach. Might be a nice example for the docs but I think we can close this (I don't have a role on this repo).
@c-moss-talk Done. Here is the example.
All I did was using the Components Framework
react-selectprovides to customize theValueContainerin whichPlaceholderresides.
Hi @Rall3n, thanks for the codesandbox! I have tried adding it to my project, but I noticed it's not working on the latest version of react-select (2.4.2 at the time of this comment). As you can see, the placeholder stays inside the container itself and not overriding it.
Do you have any idea how we can modify it to continue working?
Thanks!
Seems the sandbox was still on a very old version of the library. This commit added overflow: hidden to the ValueContainer which is the cause for your problem. Changing the style to remove overflow: hidden should make it work again.
Seems the sandbox was still on a very old version of the library. This commit added
overflow: hiddento theValueContainerwhich is the cause for your problem. Changing the style to removeoverflow: hiddenshould make it work again.
Thank you, managed to fix it by adding overflow: "visible"