Font Awesome in alert box

How do I put a font awesome icon in the anvil.alert buttons?

Below is the object construction for alert box in the documentation.

Maybe this only accepts text?

Display a large popup with a title and three buttons.
result = alert(content="Choose Red or Blue",
               title="An important choice",
               large=True,
               buttons=[
                 ("Red", "RED", "danger"),
                 ("Blue", "BLUE", "info"),
                 ("Neither", None, "default")
               ])

print "The user chose %s" % result

To note: I also tried putting icon tags in the buttons like so:

  BUTTONS = [("Sign up", "signup", "success"), 
             ("<i class="font awesome code"></i>", "google", "danger"),
             ("Log in", "login", "info")]

SweetAlerts may be a useful option here. See the example linked below.

1 Like

Hey,

Great feature request! We currently don’t support icons in the built-in alert buttons, but we’d be happy to do so. (Support-plan customers, prioritise this if you like :slight_smile: )

Otherwise, your options are:

  • Remove all built-in buttons (buttons=()), but use a Form as the content, and put buttons with icons onto that form

  • Use a third-party alert system (we generally view this as a last resort)

1 Like