FontIcon/FontAwesome in label in table

How can you use FontAwesome.xxxx in a Table?

Tried label in ColumnGenerator (does not show the icon):
Label label = new Label(“Icon Label”);
label.setIcon(FontAwesome.ADJUST);

Tried Button in ColumnGenerator (shows Icon but side effects not wanted):
Button button = new Button(“Icon Label”);
button.setIcon(FontAwesome.ADJUST);
addStyle(“link”);

but I do NOT want to use the button since it is opaque when clicked in the table.

I would like to use the setIcon (vs. a css style), unless there is a way for the css style to reference a FontAwesome character and present its iconic representation.

Thanks in advance,

javapda

Hi John,

Setting the generic icon for a Label won’t work because that icon would need to be handled by a parent layout, and the Table component doesn’t support those generic component captions, icons and error indicators.

Instead of using setIcon for the Label, set it’s value:

Label label = new Label(FontAwesome.ADJUST.getHtml(), ContentMode.HTML);

Thank you Jouni, that worked splendidly!

Thanks man, I was searching for this solution since a week!

Is there some way to set the color of the FontAwesome icon?

yes, you can use the CSS, and the addStyleName() function

Thanks. I tried that previously with no sucess. But then i tried it again today with a different css tag and it worked!
I guess it was a problem with my css. Thanks for the encouragement.

I guess I don’t understand CSS that well. Does it actually parse the tokens in a name?


final Label label = new Label(
FontAwesome.EXCLAMATION_CIRCLE.getHtml(),
ContentMode.HTML);


If i use the css name


label.addStyleName(“v-fontawesome-label-failure”);


it works

if i use


label.addStyleName(“v-label-failure”);


It does not work.

I retyped the css for v-label-failure in my sccs file just to make sure
When it does not work the table cell has a red rounded rectangle with a circle slash and the black fontAwesome

Not working in vaadin flow 18.
Any alternative for vaadin 18?