3
votes

Is there a way to use a custom icon on infoBox on shinydashboard. I am trying to use the example on hrbrmstr gist but it I can not find the place to update the infoBox function.

library(shiny)

ui <- dashboardPage(
  dashboardHeader(title = "Dynamic boxes"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      box(width = 2, actionButton("count", "Count")),
      infoBoxOutput("ibox"),
      valueBoxOutput("vbox")
    )
  )
)

server <- function(input, output) {
  output$ibox <- renderInfoBox({
    infoBox(
      "Title",
      input$count,
      #icon = icon("credit-card")
icon=icon(list(src=x, width="80px"), lib="local")
    )
  })
  output$vbox <- renderValueBox({
    valueBox(
      "Title",
      input$count,
      icon = icon("credit-card")
    )
  })
}

shinyApp(ui, server)
1

1 Answers

5
votes

I used the apputils package from leonawicz. I replaced the infoBox function with the apputils::infoBox.

library(shiny)
library(apputils)
#exApp("icons")
ui <- dashboardPage(
  dashboardHeader(title = "Dynamic boxes"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      box(width = 2, actionButton("count", "Count")),
      infoBoxOutput("ibox"),
      valueBoxOutput("vbox")
    )
  )
)

server <- function(input, output) {

  output$ibox <- renderInfoBox({
    ic <- apputils::icon(list(src = "https://cdn1.iconfinder.com/data/icons/money-47/512/Money_Currency_Finance-41-512.png", width = "80px"), lib = "local")
    apputils::infoBox(
      "Title",
      input$count,
      icon = ic
      #icon = icon("credit-card")
      #icon=icon(list(src=x, width="80px"), lib="local")
    )
  })
  output$vbox <- renderValueBox({
    valueBox(
      "Title",
      input$count,
      icon = icon("credit-card")
    )
  })
}

shinyApp(ui, server)