Can I use Fontawesome 5 Pro?

Is there a way to enable another version of Fontawesome? Since I have a license for 5 Pro, that is what I would like to use.
The Pro version has a lot more icons and icon versions.

TIA

You might want to make this a feature request.

It’s definitely something we should look to support. At the moment anvil runs font awesome version 4.7 and would need to do some adjusting to support pro versions of font awesome natively.

There are work arounds that you could implement in code now without having to wait.

E.g.


import anvil.js

def remove_fa_classes(class_list):
  return ' '.join(filter(lambda c: '' if c.startswith('fa') else c, class_list))

def add_icon(component, icon_classes): # eg. 'fas fa-fish'
  element = anvil.js.get_dom_node(component)
  icons =  element.querySelectorAll('i')
  for icon in icons:
    icon.className = remove_fa_classes(icon.classList) + ' ' + icon_classes


class Form1(Form1Template):

  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    self.init_components(**properties)
    add_icon(self.button_1, 'fas fa-fish') # your icon classes here

As a side note - if you use a newer version of fonteawesome - all (or almost all) the free icons should work as expected without this work around


self.button_1.icon = fa:fish 
# only available in fontawesome 5 but works as expected
# (assuming you've included the script tags in native-libraries)
2 Likes

Very useful. Thanks!
Will make a FR (Please support Pro and newer versions of Fontawesome)

1 Like