Pretty html formatted string on a vaadin Label

Viewed 199

how can I to add an html formatted string on a vaadin label so that it looks pretty?

It must be formatted with bold text, italic text, new lines, html things basically.

I'm using Vaadin 14. Thank you so much in advance!

2 Answers

You'll want to use new Html("");

Label corresponds to <label> and should only be used to label input fields.

Have you tried something like this:

Label label = new Label();
label.getElement().setProperty("innerHTML","Just a sentence before a line break <br /> <b> bold text</b> <br /> <i> italic text</i>");

Or this:

String yourContent = "Just a sentence before a line break <br /> <b> bold text</b> <br /> <i> italic text</i>";
Html html = new Html("<text>" + yourContent + "</text>");
Related