Style label font size

677 views Asked by At

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.

1

There are 1 answers

1
Malakai On BEST ANSWER

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