0

I'm trying to make H3 label, at this point I use built-in Vaadin theme - ValoTheme.This is how i create new label:

Label label = new Label();
label.setCaption("myLabel");
label.setStyleName(ValoTheme.LABEL_H3);

But for some reason, label keeps unstyled. The question is - how i could stylish Label without using CSS?

Thanks

P.S UI class has been annotated with @Theme(ValoTheme.THEME_NAME)

Update: Making primary button with ValoTheme styling as described above, everything works perfectly.

Malakai
  • 3,011
  • 9
  • 35
  • 49

1 Answers1

1

It took for a while to investigate and found solution that fits me best. The issue has been related to 'label.setCaption(caption);' method, which set components caption, but it denied object customizations.

Thanks to @André Schild for suggestion. So i tested these two small solutions and they worked fine:

Label label = new Label(caption);
label.setStyleName(ValoTheme.LABEL_H3);

and

Label label = new Label(caption);
label.addStyleName(ValoTheme.LABEL_H3);

I hope it helps someone

Malakai
  • 3,011
  • 9
  • 35
  • 49
  • 1
    As you noticed, a Label component has both a "value" and a "caption". The caption is something the containing layout will render, whereas the value is really what the style name affects. You can think of Label like a read-only TextField – both have a caption, and some text under the caption. – Jouni Jan 01 '17 at 14:29