How to use the icons of the "fas" "far" "fal" "fab" type from fontawesome in shiny?

Viewed 6199

I can only user "fa" Style Prefix um shiny::icon() and which creates the code like <i class="fa fa-angle-left pull-right"></i>.

How to user the others Style Prefix of fontawesome?

2 Answers

If the icon you want is in the list here: https://github.com/rstudio/shiny/blob/master/R/font-awesome.R

then it will automatically change to use "fab" as the prefix - otherwise it will always use "fa" I think. The relevant code from inside shiny::icon is:

if (!is.null(name)) {
        prefix_class <- prefix
        if (prefix_class == "fa" && name %in% font_awesome_brands) {
            prefix_class <- "fab"
        }
        iconClass <- paste0(prefix_class, " ", prefix, "-", name)
    }

You can change the prefix by creating the icon yourself

htmltools::browsable(tags$i(class = "far fa-user-circle"))

This can be passed in the icon argument of shiny ui elements

actionButton(..., icon = htmltools::browsable(tags$i(class = "far fa-user-circle")))
Related