Home > Software design >  How to overcome width parameter in shinyDashboard valueBox being ignored when wrapped in renderUI an
How to overcome width parameter in shinyDashboard valueBox being ignored when wrapped in renderUI an

Time:11-04

I am wanting to create shinyDashboard valueBoxes. The number of these is variable depending on select inputs, so I have followed enter image description here

I have tried inline=TRUE in htmlOutput but this makes no difference. How can I make the width=2 be respected or where do I need to move this to? Thanks

CodePudding user response:

Change htmlOutput to valueBoxOutput:

  output$stats <- renderUI({
    vboxes <- lapply(1:nstats, function(i) {
      outputId <- paste0("valuebox_", i)
      valueBoxOutput(outputId)
    })
    tagList(vboxes)
  })

enter image description here

As an aside, I think this is a classic example of where using modules would be beneficial. It would mean you wouldn't need to track the valueBox IDs in the server or UI, and could delegate all the manipulation of the data in the value box to the module. This will make your main ui and server functions shorter and cleaner.

  • Related