0

what I need to do is to combine these two subtitles together. in Html file, it shows all the subtitle content is under a

tag. I tried HTML and paste but not working.

output$id <- renderInfoBox({
    infoBox(
      title = "title",
      value = value,
      icon = icon(),
      subtitle = tags$a(icon("question-circle"),id="id"),
      subtitle = "description"
   )
  })
Yan
  • 1
  • 1
  • Are you use shinydashboard? – Rolando Tamayo Jun 25 '20 at 04:59
  • I'm trying to replicate your example to try to understand your problem but I can't really get it. Could you be more specific, maybe share an image of what you hope to achieve and an excerpt from the application's ui? – Rolando Tamayo Jun 25 '20 at 05:10
  • I got "Error: formal argument "subtitle" matched by multiple actual arguments" – Rolando Tamayo Jun 25 '20 at 05:11
  • output$median <- renderInfoBox({ infoBox( title = "this is median value ", value = median(mtcars$mpg), icon = icon("usd"), subtitle = tags$a(icon("question-circle"),id="q1"), ) }) – Yan Jun 25 '20 at 06:00
  • bsPopover( id = "q1", title = "Median", content = "Median value ", trigger = "hover", placement = "right", options = list(container = "body") ), – Yan Jun 25 '20 at 06:00
  • what I need is to add another subtitle which is a description like this "this is description". how can I make it? – Yan Jun 25 '20 at 06:02

1 Answers1

1

The following is a simple application where that use a InfoBox. I tried to use the same parameters as your example, except I used value = 20.

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Info boxes"),
  dashboardSidebar(),
  dashboardBody(
  #Show infobox in ui
    infoBoxOutput("id")
  )
)

server <- function(input, output) {
  
  output$id <- renderInfoBox({
    infoBox(
      #We only have 3 parameters to show information
      title = "title", 
      value = 20,
      subtitle = "description",
      icon = icon("question-circle")
    )
  })
  
}

shinyApp(ui, server)

enter image description here

As already mentioned we only have 3 parameters to write or display information: title, value and subtitle.

You were trying to put an icon in the subtitle parameter, and this should go in the icon parameter.

Then you can use the subtitle parameter to write several lines if you wish.

  subtitle = tags$a(icon("question-circle"),"This ia a descrpcion"))

enter image description here

If you are looking to make a more complex design you should check the Box function.

Rolando Tamayo
  • 286
  • 2
  • 8