25

When using shinydashboard I find that some icons seem to work while some don't. In the below example, the battery-full icon doesn't work while the clock-o icon works fine. I'm unable to figure out why this should happen.

library(shiny)
library(shinydashboard)

header <- dashboardHeader(title="Some Icons Not Working?")

# No sidebar --------------------------------------------------------------

sm <- sidebarMenu(

  sm <- sidebarMenu(
    menuItem(
      text="asdf",
      tabName="asdfasdf",
      icon=icon("battery-full")),
    menuItem(
      text="qwer",
      tabName="qwerqwer",
      icon=icon("clock-o"))
  )
)

sidebar <- dashboardSidebar(sm)

# Compose dashboard body --------------------------------------------------

body <- dashboardBody(

  tabItems(

  )
)

# Setup Shiny app UI components -------------------------------------------

ui <- dashboardPage(header, sidebar, body, skin="black")

# Setup Shiny app back-end components -------------------------------------

server <- function(input, output) {


}

# Render Shiny app --------------------------------------------------------

shinyApp(ui, server)
TheComeOnMan
  • 12,535
  • 8
  • 39
  • 54

6 Answers6

15

Ok, I think the new ones in version 4.4 are not updated. You can probably request shiny team to update them and they will do it very easily. Alternatively you can do it yourself by downloading them and replacing the previous content...

1. Go to the Font Awesome download page and get it enter image description here

2. Locate your font awesome folder where you installed shiny package. This should be somewhere like here ~\Documents\R\win-library\3.1\shiny\www\shared\font-awesome

3. Replace the content of this folder with new contents (you can delete the previous content if you want). Below is what I put in there enter image description here

4. Now your app should work fine with new fonts enter image description here

Pork Chop
  • 28,528
  • 5
  • 63
  • 77
  • Note: I don't think this solution works for the latest version of fa https://github.com/rstudio/shiny/issues/1966 – GISHuman Jul 12 '18 at 13:04
  • Well, the ticket is from 3 years go. A lot has changed – Pork Chop Jul 12 '18 at 13:08
  • Any other way to fix this problem? – Lavanya Jul 14 '18 at 02:41
  • 1
    You can ping the guys from shiny on github and ask them to release it into the dev version https://github.com/rstudio/shiny/issues – Pork Chop Jul 14 '18 at 09:11
  • some reasons it might not have worked are some differences in how to link to old and new fa-library, here is a code-example to haev both fontawesome 5 and 4 in shiny 1.2 https://stackoverflow.com/questions/54464295/shiny-downgrade-fontawesome-5-to-4 – Soren Havelund Welling Feb 05 '19 at 23:44
  • 1
    @PorkChop I'm using the pro version of fa. Your solution works very well for me locally, but not when I deploy my app to shinyapps.io. (note that I did include my pro `font-awesome` directory inside the `www` folder of my app). Seems like there is no way to tell the [icon()](https://www.rdocumentation.org/packages/shiny/versions/1.2.0/topics/icon) function to look at the local version of font-awesome – Antoine Mar 14 '19 at 12:44
  • @PorkChop I asked a question regarding my comment above: https://stackoverflow.com/questions/55163719/r-shiny-wow-to-use-fontawesome-pro-version-with-the-icon-function – Antoine Mar 14 '19 at 13:25
  • @PorkChop since a lot has changed with fontawesome since 2018, it would be nice to update this answer. – Lazarus Thurston Feb 13 '22 at 17:01
15

For those newcomers in 2021, this icon ... does not exist error is due to the Font Awesome changing names to their icons between 4 and 5 (see background here). Below are solutions that do not require tag styles.

If you are getting this error message,

This Font Awesome icon ('{youriconname}') does not exist:

* if providing a custom html_dependency these name checks can be deactivated with verify_fa = FALSE

then, you can either:

  1. Embrace the change and rename your icon, looking at the library, link to 5.1.5 for example, to find a new name for your match. In my case it was changing icon('dashboard') to icon('tachometer-alt'). Search with your old name, and look at the free, not grayed out, icons for an alternative.

  2. Use this useful workaround by @samssann from shinydashboard issue 373:

    1. add verify_fa = FALSE argument to shiny::icon()
    2. use shiny::icon("clock") or fontawesome::fa("clock")

P.S. You might find the icon still shows on your app despite the error as there is a shim to plug 4 to 5. See @jcheng's answer here from shiny issue #1966.

micstr
  • 5,080
  • 8
  • 48
  • 76
14

This is an older question, but the issue remains for me in July 2020. I found the solution in the github issues page. The trick is to make sure you are looking at the library of icons in the version of Font Awesome Shiny is calling. Currently (again, July 2020) the version is 4.7. All of these icons currently work.

Another option is to call the version of fontawesome you want using the following code within your app's ui function (this solution originally posted here):

tags$style("@import url(https://use.fontawesome.com/releases/v5.7.2/css/all.css);")
DanWaters
  • 517
  • 5
  • 13
5

Now that shiny::icon is powered by the fontawesome r package, you can use fontawesome:::fa_tbl to help you find the names that are expected from the function. fontawesome:::fa_version also tells you what fontawesome version is currently in the R package.

0

For me, in Oct 2020, solution was adding a "s" after first "fa", as in fa fa-caret-up to fas fa-caret-up since it's the new syntax for font awesome icons.

micstr
  • 5,080
  • 8
  • 48
  • 76
Alberson Miranda
  • 1,248
  • 7
  • 25
0

I've developed a shiny app where I had this problem. To fix this I only install the library and all worked.

install.packages("fontawesome")

or

devtools::install_github("rstudio/fontawesome")

You can find more information here