Search code examples
javavaadinvaadin8

In Vaadin how can I set a style within a Label and NOT have it affect the whole page


So for example I set the following html code in my Label:

Label label = new Label();
label.setContentMode(ContentMode.HTML);
label.setValue("<style> * { font-size: 12px; font-family: Arial; } </style> hello world");

The problem with the above code is that it sets the whole page to the Arial and NOT just the Label. If I use a RichTextArea then it ONLY sets the style to that component but for whatever reason any css styles defined in the Label are applied to the whole page...

FYI - If you set a RichTextArea to read only you get the exact same issue...


Solution

  • What I ended up using was a BrowserFrame. The only thing is that the BrowserFrame's height cannot be resized dynamically like a Label with a -1px.