Descriptive default text for TextField?

Hello everyone,

all over the internet, one can find text fields that have a (usually grayed-out or italic) text in them, but when the user clicks into the text field and starts typing, this “default text” disappears.
Take the “Search Forum” text field in this very forum for example. The text says “Search Forum” (printed in gray), but when you click into it and start typing, the text “Search Forum” automatically disappears and will not re-appear until the widget looses focus while it has no text in it.

Is it possible to do this with Vaadin TextFields? Most likely there is a special term for such a behaviour, I couldn’t find any related info.

Thank you,

Martin

EDIT: I finally found it! In Vaadin, this is called “input prompt”!

What you’re looking for is textfield.setInputPrompt(“…”) as can be seen here:
http://demo.vaadin.com/sampler/#ui/data-input/text-input/text-field

Yes thank you, just stumbled across this myself, I’ve been looking for this for ages :wink: