mitchelloharawild / icons

R package to easily insert web icons to RMarkdown
https://pkg.mitchelloharawild.com/icons
313 stars 43 forks source link

Investigate possibility of passing {icons} icons to the shiny `icon=` argument #59

Closed mitchelloharawild closed 1 year ago

mitchelloharawild commented 3 years ago

Related: https://community.rstudio.com/t/use-of-open-source-icons-in-shiny/110056/5

Moohan commented 1 year ago

This worked for me (and was the motivation behind Tom Jemmett doing #73)

I tried something like this in our existing Shiny Dashboard and it seemed to work fine.

 tabPanel(
        title = "Home",
        icon = icons::health_icons("blood_bag"),
        ...)

This was a direct swap for icon = icon("building") i.e. shiny::icon that was there before.

mitchelloharawild commented 1 year ago

Thanks! I'm closing this since this is a limitation of shiny's validateIcon() function which is used in actionButton(). The equivalent result for buttons can be obtained with actionButton("rocket", list(fontawesome$solid$rocket, "Rocket")).

mitchelloharawild commented 1 year ago

Minimal example:

library(shiny)
library(icons)

ui <- fluidPage(
  actionButton("d1", "Rocket", icon = icon("rocket")),
  actionButton("rocket", list(fontawesome$solid$rocket, "Rocket"))
)

server <- function(input, output) {}
shinyApp(ui = ui, server = server)